From 456ec7fd53ea3187941bbf384eb97110d45d5bdc Mon Sep 17 00:00:00 2001
From: DedunuKarunarathne
<46235093+DedunuKarunarathne@users.noreply.github.com>
Date: Fri, 22 Sep 2023 10:01:01 +0530
Subject: [PATCH 001/281] Update groupId and the version
---
.../accelerators/ob-apim/pom.xml | 4 +--
.../accelerators/ob-bi/pom.xml | 4 +--
.../pom.xml | 8 ++---
.../openbanking-consent-endpoint/pom.xml | 12 ++++----
.../pom.xml | 8 ++---
.../pom.xml | 8 ++---
.../accelerators/ob-is/pom.xml | 4 +--
open-banking-accelerator/accelerators/pom.xml | 4 +--
.../pom.xml | 6 ++--
.../pom.xml | 10 +++----
.../pom.xml | 4 +--
.../pom.xml | 8 ++---
.../pom.xml | 6 ++--
.../pom.xml | 4 +--
.../pom.xml | 8 ++---
.../pom.xml | 16 +++++-----
.../pom.xml | 6 ++--
.../pom.xml | 6 ++--
.../pom.xml | 4 +--
.../pom.xml | 6 ++--
.../pom.xml | 14 ++++-----
.../pom.xml | 6 ++--
.../pom.xml | 8 ++---
.../pom.xml | 12 ++++----
.../pom.xml | 6 ++--
.../pom.xml | 8 ++---
.../pom.xml | 8 ++---
.../pom.xml | 8 ++---
.../pom.xml | 12 ++++----
.../pom.xml | 8 ++---
.../pom.xml | 6 ++--
.../pom.xml | 6 ++--
.../pom.xml | 10 +++----
.../pom.xml | 8 ++---
.../pom.xml | 8 ++---
open-banking-accelerator/pom.xml | 6 ++--
.../bfsi-apps/consent-approval-ui/pom.xml | 8 ++---
.../consent-manager-dashboard/pom.xml | 8 ++---
open-banking-react-apps/bfsi-bff/pom.xml | 8 ++---
open-banking-react-apps/pom.xml | 4 +--
.../components/aggregator-gateway/pom.xml | 6 ++--
.../components/aggregator-identity/pom.xml | 10 +++----
open-banking-sample-toolkit/pom.xml | 4 +--
pom.xml | 30 +++++++++----------
react-apps/pom.xml | 4 +--
react-apps/self-care-portal/pom.xml | 8 ++---
46 files changed, 180 insertions(+), 180 deletions(-)
diff --git a/open-banking-accelerator/accelerators/ob-apim/pom.xml b/open-banking-accelerator/accelerators/ob-apim/pom.xml
index d5cb6c64..46ba6e36 100644
--- a/open-banking-accelerator/accelerators/ob-apim/pom.xml
+++ b/open-banking-accelerator/accelerators/ob-apim/pom.xml
@@ -23,9 +23,9 @@
4.0.0
- com.wso2
+ com.wso2.openbanking.acceleratoropen-banking
- 3.0.0
+ 3.1.0../pom.xml
diff --git a/open-banking-accelerator/accelerators/ob-bi/pom.xml b/open-banking-accelerator/accelerators/ob-bi/pom.xml
index b7e41ee0..f4f33ae6 100644
--- a/open-banking-accelerator/accelerators/ob-bi/pom.xml
+++ b/open-banking-accelerator/accelerators/ob-bi/pom.xml
@@ -23,9 +23,9 @@
4.0.0
- com.wso2
+ com.wso2.openbanking.acceleratoropen-banking
- 3.0.0
+ 3.1.0../pom.xml
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#application/META-INF/maven/com.wso2/openbanking-application-info-endpoint/pom.xml b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#application/META-INF/maven/com.wso2/openbanking-application-info-endpoint/pom.xml
index 6af5d071..40b9c67e 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#application/META-INF/maven/com.wso2/openbanking-application-info-endpoint/pom.xml
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#application/META-INF/maven/com.wso2/openbanking-application-info-endpoint/pom.xml
@@ -22,8 +22,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../../pom.xml4.0.0
@@ -64,12 +64,12 @@
provided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.commonprovided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.identityprovided
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#consent/META-INF/maven/com.wso2/openbanking-consent-endpoint/pom.xml b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#consent/META-INF/maven/com.wso2/openbanking-consent-endpoint/pom.xml
index 6a9e406d..37e6b8cf 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#consent/META-INF/maven/com.wso2/openbanking-consent-endpoint/pom.xml
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#consent/META-INF/maven/com.wso2/openbanking-consent-endpoint/pom.xml
@@ -24,8 +24,8 @@
open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../../pom.xml
@@ -63,7 +63,7 @@
test
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.identity
@@ -74,7 +74,7 @@
provided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.consent.dao
@@ -85,7 +85,7 @@
provided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.consent.service
@@ -107,7 +107,7 @@
provided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.consent.extensions
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#dynamic-client-registration/META-INF/maven/com.wso2/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#dynamic-client-registration/META-INF/maven/com.wso2/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
index ceabea67..0d6043e1 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#dynamic-client-registration/META-INF/maven/com.wso2/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#dynamic-client-registration/META-INF/maven/com.wso2/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
@@ -21,8 +21,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../../pom.xml4.0.0
@@ -67,7 +67,7 @@
provided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.identity
@@ -78,7 +78,7 @@
provided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.commonprovided
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/ob#authenticationendpoint/META-INF/maven/com.wso2/com.wso2.openbanking.authentication.webapp/pom.xml b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/ob#authenticationendpoint/META-INF/maven/com.wso2/com.wso2.openbanking.authentication.webapp/pom.xml
index aec46e33..ab4a56b8 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/ob#authenticationendpoint/META-INF/maven/com.wso2/com.wso2.openbanking.authentication.webapp/pom.xml
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/ob#authenticationendpoint/META-INF/maven/com.wso2/com.wso2.openbanking.authentication.webapp/pom.xml
@@ -22,8 +22,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../../pom.xml4.0.0
@@ -34,12 +34,12 @@
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.identityprovided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.consent.extensionsprovided
diff --git a/open-banking-accelerator/accelerators/ob-is/pom.xml b/open-banking-accelerator/accelerators/ob-is/pom.xml
index e3f9a5c2..c60159db 100644
--- a/open-banking-accelerator/accelerators/ob-is/pom.xml
+++ b/open-banking-accelerator/accelerators/ob-is/pom.xml
@@ -23,9 +23,9 @@
4.0.0
- com.wso2
+ com.wso2.openbanking.acceleratoropen-banking
- 3.0.0
+ 3.1.0../pom.xml
diff --git a/open-banking-accelerator/accelerators/pom.xml b/open-banking-accelerator/accelerators/pom.xml
index 286193d6..b51f03f1 100644
--- a/open-banking-accelerator/accelerators/pom.xml
+++ b/open-banking-accelerator/accelerators/pom.xml
@@ -21,9 +21,9 @@
4.0.0
- com.wso2
+ com.wso2.openbanking.acceleratoropen-banking
- 3.0.0
+ 3.1.0../../pom.xml
diff --git a/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml b/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml
index d687f956..9fedd7e2 100644
--- a/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml
+++ b/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml
@@ -18,8 +18,8 @@
open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../../pom.xml4.0.0
@@ -72,7 +72,7 @@
powermock-api-mockito
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.common
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.ciba/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.ciba/pom.xml
index ebefa72d..cdfe4b74 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.ciba/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.ciba/pom.xml
@@ -24,8 +24,8 @@
open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../pom.xmlcom.wso2.openbanking.accelerator.ciba
@@ -33,12 +33,12 @@
WSO2 Open Banking - Common component
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.commonprovided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.identityprovided
@@ -61,7 +61,7 @@
powermock-api-mockito
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.consent.service
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
index 367041df..1faab072 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
@@ -24,8 +24,8 @@
open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml
index 076a0d06..7283cdf2 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml
@@ -24,8 +24,8 @@
com.wso2.openbanking.accelerator.data.publisher
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../pom.xml
@@ -47,11 +47,11 @@
org.wso2.carbon.identity.application.authentication.framework
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.data.publisher.common
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.common
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
index 00443cc8..048643c1 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
@@ -21,8 +21,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../../pom.xml4.0.0
@@ -37,7 +37,7 @@
org.wso2.carbon.databridge.agent
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.common
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml
index d985fa21..8ac8bf7b 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml
@@ -21,8 +21,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
index 126980e1..59b562cb 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
@@ -24,8 +24,8 @@
open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../pom.xml
@@ -46,7 +46,7 @@
commons-logging
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.common
@@ -62,7 +62,7 @@
swagger-parser
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.data.publisher.common
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml
index f485600d..978850c5 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml
@@ -21,8 +21,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../pom.xml4.0.0
@@ -40,7 +40,7 @@
org.eclipse.osgi
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.commonprovided
@@ -147,23 +147,23 @@
test
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.data.publisher.common
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.consent.service
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.consent.dao
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.throttler.dao
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.throttler.service
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml
index 588d88eb..9d5319cf 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml
@@ -19,8 +19,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../pom.xml4.0.0
@@ -39,7 +39,7 @@
org.eclipse.osgi
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.commonprovided
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml
index 04235d4b..3304ba11 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml
@@ -21,8 +21,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
com.wso2.openbanking.accelerator.runtime
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../pom.xml
@@ -57,7 +57,7 @@
provided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.identityprovided
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml
index 8e9b4843..7ac8f3bb 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml
@@ -21,8 +21,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml
index 905e0d12..1ceb2488 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml
@@ -22,8 +22,8 @@
open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../pom.xml
@@ -37,7 +37,7 @@
org.wso2.carbon.core
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.common
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml
index 6387d695..37e9dfc1 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml
@@ -23,8 +23,8 @@
open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../../pom.xml
@@ -39,11 +39,11 @@
provided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.common
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.identity
@@ -61,11 +61,11 @@
test
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.consent.service
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.consent.daoprovided
@@ -102,7 +102,7 @@
org.wso2.carbon.identity.application.authenticator.push
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.event.notifications.service
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
index 6e3d2768..ab07daa4 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
@@ -21,8 +21,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../../pom.xml4.0.0
@@ -34,7 +34,7 @@
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.commonprovided
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml
index 947f853d..e6089c41 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml
@@ -22,8 +22,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../../pom.xml4.0.0
@@ -35,7 +35,7 @@
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.commonprovided
@@ -50,7 +50,7 @@
provided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.consent.daoprovided
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml
index 72ea5539..afdb277a 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml
@@ -18,8 +18,8 @@
open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../../pom.xml4.0.0
@@ -62,15 +62,15 @@
powermock-api-mockito
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.identity
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.consent.service
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.commonprovided
@@ -81,7 +81,7 @@
test
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.common
diff --git a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml
index 6a72ebdb..002d5000 100644
--- a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml
+++ b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml
@@ -21,8 +21,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../../pom.xml4.0.0
@@ -34,7 +34,7 @@
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.commonprovided
diff --git a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml
index db7c0224..8c4c023c 100644
--- a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml
+++ b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml
@@ -21,8 +21,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../../pom.xml4.0.0
@@ -34,12 +34,12 @@
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.commonprovided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.throttler.daoprovided
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml
index 6af5d071..40b9c67e 100755
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml
@@ -22,8 +22,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../../pom.xml4.0.0
@@ -64,12 +64,12 @@
provided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.commonprovided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.identityprovided
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml
index d4fd068c..d8e0751b 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml
@@ -17,8 +17,8 @@
-->open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../../pom.xml4.0.0
@@ -35,7 +35,7 @@
test
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.consent.extensionsprovided
@@ -45,7 +45,7 @@
provided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.commonprovided
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml
index 6a9e406d..37e6b8cf 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml
@@ -24,8 +24,8 @@
open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../../pom.xml
@@ -63,7 +63,7 @@
test
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.identity
@@ -74,7 +74,7 @@
provided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.consent.dao
@@ -85,7 +85,7 @@
provided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.consent.service
@@ -107,7 +107,7 @@
provided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.consent.extensions
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
index ceabea67..0d6043e1 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
@@ -21,8 +21,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../../pom.xml4.0.0
@@ -67,7 +67,7 @@
provided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.identity
@@ -78,7 +78,7 @@
provided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.commonprovided
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml
index 89ba7125..20c5ca2b 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml
@@ -22,8 +22,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../../pom.xml4.0.0
@@ -43,7 +43,7 @@
${spotbugs.annotations.version}
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.common
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demosite.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demosite.endpoint/pom.xml
index e41c09a6..0e01e9b9 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demosite.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demosite.endpoint/pom.xml
@@ -21,8 +21,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
open-banking
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../../pom.xml4.0.0
@@ -52,7 +52,7 @@
provided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.commonprovided
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml
index 0a197b68..18a90ac6 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml
@@ -18,8 +18,8 @@
open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../../pom.xml4.0.0
@@ -63,7 +63,7 @@
provided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.commonprovided
@@ -104,7 +104,7 @@
provided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.event.notifications.service
@@ -115,7 +115,7 @@
provided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.consent.extensionsprovided
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml
index 3871f338..54cc7383 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml
@@ -24,8 +24,8 @@
open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../../pom.xml
@@ -54,12 +54,12 @@
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.identityprovided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.runtime.identity.authn.filterprovided
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml
index aec46e33..ab4a56b8 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml
@@ -22,8 +22,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
open-banking-accelerator
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../../pom.xml4.0.0
@@ -34,12 +34,12 @@
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.identityprovided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.consent.extensionsprovided
diff --git a/open-banking-accelerator/pom.xml b/open-banking-accelerator/pom.xml
index 5490dbba..a7179e8f 100644
--- a/open-banking-accelerator/pom.xml
+++ b/open-banking-accelerator/pom.xml
@@ -23,16 +23,16 @@
4.0.0
- com.wso2
+ com.wso2.openbanking.acceleratoropen-banking
- 3.0.0
+ 3.1.0../pom.xmlWSO2 Open Banking Acceleratoropen-banking-acceleratorpom
- 3.0.0
+ 3.1.0components/com.wso2.openbanking.accelerator.common
diff --git a/open-banking-react-apps/bfsi-apps/consent-approval-ui/pom.xml b/open-banking-react-apps/bfsi-apps/consent-approval-ui/pom.xml
index f4a198de..96109e3d 100644
--- a/open-banking-react-apps/bfsi-apps/consent-approval-ui/pom.xml
+++ b/open-banking-react-apps/bfsi-apps/consent-approval-ui/pom.xml
@@ -22,9 +22,9 @@
4.0.0
- com.wso2
+ com.wso2.openbanking.acceleratoropen-banking-react-apps
- 3.0.0
+ 3.1.0../../pom.xml
@@ -40,12 +40,12 @@
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.identityprovided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.commonprovided
diff --git a/open-banking-react-apps/bfsi-apps/consent-manager-dashboard/pom.xml b/open-banking-react-apps/bfsi-apps/consent-manager-dashboard/pom.xml
index 666d5482..326b656e 100644
--- a/open-banking-react-apps/bfsi-apps/consent-manager-dashboard/pom.xml
+++ b/open-banking-react-apps/bfsi-apps/consent-manager-dashboard/pom.xml
@@ -22,9 +22,9 @@
4.0.0
- com.wso2
+ com.wso2.openbanking.acceleratoropen-banking-react-apps
- 3.0.0
+ 3.1.0../../pom.xml
@@ -42,12 +42,12 @@
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.identityprovided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.commonprovided
diff --git a/open-banking-react-apps/bfsi-bff/pom.xml b/open-banking-react-apps/bfsi-bff/pom.xml
index 5d3875d6..8a9f5fb3 100644
--- a/open-banking-react-apps/bfsi-bff/pom.xml
+++ b/open-banking-react-apps/bfsi-bff/pom.xml
@@ -22,9 +22,9 @@
4.0.0
- com.wso2
+ com.wso2.openbanking.acceleratoropen-banking-react-apps
- 3.0.0
+ 3.1.0../pom.xml
@@ -40,12 +40,12 @@
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.identityprovided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.commonprovided
diff --git a/open-banking-react-apps/pom.xml b/open-banking-react-apps/pom.xml
index 280f151e..d894c92c 100644
--- a/open-banking-react-apps/pom.xml
+++ b/open-banking-react-apps/pom.xml
@@ -23,9 +23,9 @@
4.0.0
- com.wso2
+ com.wso2.openbanking.acceleratoropen-banking
- 3.0.0
+ 3.1.0../pom.xml
diff --git a/open-banking-sample-toolkit/components/aggregator-gateway/pom.xml b/open-banking-sample-toolkit/components/aggregator-gateway/pom.xml
index 2267a4c5..d03f4da5 100644
--- a/open-banking-sample-toolkit/components/aggregator-gateway/pom.xml
+++ b/open-banking-sample-toolkit/components/aggregator-gateway/pom.xml
@@ -20,8 +20,8 @@
4.0.0open-banking-sample-toolkit
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../pom.xmlcom.wso2.openbanking.sample.aggregator.gateway
@@ -33,7 +33,7 @@
org.wso2.carbon.apimgt.common.gateway
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.gateway
diff --git a/open-banking-sample-toolkit/components/aggregator-identity/pom.xml b/open-banking-sample-toolkit/components/aggregator-identity/pom.xml
index a8a9309d..8d6e1b95 100644
--- a/open-banking-sample-toolkit/components/aggregator-identity/pom.xml
+++ b/open-banking-sample-toolkit/components/aggregator-identity/pom.xml
@@ -21,8 +21,8 @@
4.0.0open-banking-sample-toolkit
- com.wso2
- 3.0.0
+ com.wso2.openbanking.accelerator
+ 3.1.0../../pom.xmlcom.wso2.openbanking.sample.aggregator.identity
@@ -30,7 +30,7 @@
WSO2 Open Banking - Sample Aggregator Identity
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.identity
@@ -46,11 +46,11 @@
json-smart
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.consent.service
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.consent.extensions
diff --git a/open-banking-sample-toolkit/pom.xml b/open-banking-sample-toolkit/pom.xml
index 58e179b1..42abb661 100644
--- a/open-banking-sample-toolkit/pom.xml
+++ b/open-banking-sample-toolkit/pom.xml
@@ -20,9 +20,9 @@
4.0.0
- com.wso2
+ com.wso2.openbanking.acceleratoropen-banking
- 3.0.0
+ 3.1.0../pom.xmlopen-banking-sample-toolkit
diff --git a/pom.xml b/pom.xml
index c2a91881..28ff2b43 100644
--- a/pom.xml
+++ b/pom.xml
@@ -18,10 +18,10 @@
4.0.0
- com.wso2
+ com.wso2.openbanking.acceleratoropen-bankingpom
- 3.0.0
+ 3.1.0
@@ -253,67 +253,67 @@
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.common${project.version}
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.gateway${project.version}
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.identity${project.version}
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.runtime.identity.authn.filter${project.version}
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.consent.extensions${project.version}
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.data.publisher.common${project.version}
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.keymanager${project.version}
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.consent.service${project.version}
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.consent.dao${project.version}
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.throttler.dao${project.version}
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.throttler.service${project.version}
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.event.notifications.service${project.version}
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.event.notifications.endpoint${project.version}
diff --git a/react-apps/pom.xml b/react-apps/pom.xml
index 5f9dab7f..36db0e70 100644
--- a/react-apps/pom.xml
+++ b/react-apps/pom.xml
@@ -22,9 +22,9 @@
4.0.0
- com.wso2
+ com.wso2.openbanking.acceleratoropen-banking
- 3.0.0
+ 3.1.0../pom.xml
diff --git a/react-apps/self-care-portal/pom.xml b/react-apps/self-care-portal/pom.xml
index d2078c4e..70997838 100644
--- a/react-apps/self-care-portal/pom.xml
+++ b/react-apps/self-care-portal/pom.xml
@@ -23,9 +23,9 @@
4.0.0
- com.wso2
+ com.wso2.openbanking.acceleratorreact-apps
- 3.0.0
+ 3.1.0../pom.xml
@@ -39,12 +39,12 @@
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.identityprovided
- com.wso2
+ com.wso2.openbanking.acceleratorcom.wso2.openbanking.accelerator.commonprovided
From 48b3fe06f09b2d02fc17b9d8b4d473fecc20dc67 Mon Sep 17 00:00:00 2001
From: DedunuKarunarathne
<46235093+DedunuKarunarathne@users.noreply.github.com>
Date: Tue, 26 Sep 2023 12:47:25 +0530
Subject: [PATCH 002/281] Add the parent project
---
pom.xml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/pom.xml b/pom.xml
index 28ff2b43..8047d1c8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,6 +23,12 @@
pom3.1.0
+
+ org.wso2
+ wso2
+ 5
+
+
dev
From 59ecb6544bd558400d4d6eb335b12d811970c9e8 Mon Sep 17 00:00:00 2001
From: DedunuKarunarathne
<46235093+DedunuKarunarathne@users.noreply.github.com>
Date: Tue, 26 Sep 2023 13:03:59 +0530
Subject: [PATCH 003/281] change verison
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 8047d1c8..94cf16d4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,7 @@
org.wso2wso2
- 5
+ 2
From e8bb825131cd39088962626836eef96101041877 Mon Sep 17 00:00:00 2001
From: DedunuKarunarathne
<46235093+DedunuKarunarathne@users.noreply.github.com>
Date: Tue, 26 Sep 2023 14:10:11 +0530
Subject: [PATCH 004/281] make version snapshot
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 94cf16d4..b43d9bcc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,7 +21,7 @@
com.wso2.openbanking.acceleratoropen-bankingpom
- 3.1.0
+ 3.1.0-SNAPSHOTorg.wso2
From 9f7addee0e1d6cc9618e913616ebd34d444bfe68 Mon Sep 17 00:00:00 2001
From: DedunuKarunarathne
<46235093+DedunuKarunarathne@users.noreply.github.com>
Date: Tue, 26 Sep 2023 18:22:57 +0530
Subject: [PATCH 005/281] make versions snapshot
---
open-banking-accelerator/accelerators/ob-apim/pom.xml | 2 +-
open-banking-accelerator/accelerators/ob-bi/pom.xml | 2 +-
.../com.wso2/openbanking-application-info-endpoint/pom.xml | 2 +-
.../maven/com.wso2/openbanking-consent-endpoint/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml | 2 +-
.../com.wso2.openbanking.authentication.webapp/pom.xml | 2 +-
open-banking-accelerator/accelerators/ob-is/pom.xml | 2 +-
open-banking-accelerator/accelerators/pom.xml | 2 +-
.../pom.xml | 2 +-
.../components/com.wso2.openbanking.accelerator.ciba/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.common/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.data.publisher/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.gateway/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.identity/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.keymanager/pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.runtime/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.throttler.dao/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.consent.endpoint/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.demo.backend/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.authentication.webapp/pom.xml | 2 +-
open-banking-accelerator/pom.xml | 4 ++--
open-banking-react-apps/bfsi-apps/consent-approval-ui/pom.xml | 2 +-
.../bfsi-apps/consent-manager-dashboard/pom.xml | 2 +-
open-banking-react-apps/bfsi-bff/pom.xml | 2 +-
open-banking-react-apps/pom.xml | 2 +-
.../components/aggregator-gateway/pom.xml | 2 +-
.../components/aggregator-identity/pom.xml | 2 +-
open-banking-sample-toolkit/pom.xml | 2 +-
react-apps/pom.xml | 2 +-
react-apps/self-care-portal/pom.xml | 2 +-
45 files changed, 46 insertions(+), 46 deletions(-)
diff --git a/open-banking-accelerator/accelerators/ob-apim/pom.xml b/open-banking-accelerator/accelerators/ob-apim/pom.xml
index 46ba6e36..c246b9d0 100644
--- a/open-banking-accelerator/accelerators/ob-apim/pom.xml
+++ b/open-banking-accelerator/accelerators/ob-apim/pom.xml
@@ -25,7 +25,7 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.1.0
+ 3.1.0-SNAPSHOT../pom.xml
diff --git a/open-banking-accelerator/accelerators/ob-bi/pom.xml b/open-banking-accelerator/accelerators/ob-bi/pom.xml
index f4f33ae6..da0a5d37 100644
--- a/open-banking-accelerator/accelerators/ob-bi/pom.xml
+++ b/open-banking-accelerator/accelerators/ob-bi/pom.xml
@@ -25,7 +25,7 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.1.0
+ 3.1.0-SNAPSHOT../pom.xml
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#application/META-INF/maven/com.wso2/openbanking-application-info-endpoint/pom.xml b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#application/META-INF/maven/com.wso2/openbanking-application-info-endpoint/pom.xml
index 40b9c67e..cc3e67bb 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#application/META-INF/maven/com.wso2/openbanking-application-info-endpoint/pom.xml
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#application/META-INF/maven/com.wso2/openbanking-application-info-endpoint/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#consent/META-INF/maven/com.wso2/openbanking-consent-endpoint/pom.xml b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#consent/META-INF/maven/com.wso2/openbanking-consent-endpoint/pom.xml
index 37e6b8cf..ba795904 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#consent/META-INF/maven/com.wso2/openbanking-consent-endpoint/pom.xml
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#consent/META-INF/maven/com.wso2/openbanking-consent-endpoint/pom.xml
@@ -25,7 +25,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../../pom.xml
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#dynamic-client-registration/META-INF/maven/com.wso2/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#dynamic-client-registration/META-INF/maven/com.wso2/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
index 0d6043e1..35b937f0 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#dynamic-client-registration/META-INF/maven/com.wso2/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#dynamic-client-registration/META-INF/maven/com.wso2/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/ob#authenticationendpoint/META-INF/maven/com.wso2/com.wso2.openbanking.authentication.webapp/pom.xml b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/ob#authenticationendpoint/META-INF/maven/com.wso2/com.wso2.openbanking.authentication.webapp/pom.xml
index ab4a56b8..b4fa5978 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/ob#authenticationendpoint/META-INF/maven/com.wso2/com.wso2.openbanking.authentication.webapp/pom.xml
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/ob#authenticationendpoint/META-INF/maven/com.wso2/com.wso2.openbanking.authentication.webapp/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/accelerators/ob-is/pom.xml b/open-banking-accelerator/accelerators/ob-is/pom.xml
index c60159db..201cb569 100644
--- a/open-banking-accelerator/accelerators/ob-is/pom.xml
+++ b/open-banking-accelerator/accelerators/ob-is/pom.xml
@@ -25,7 +25,7 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.1.0
+ 3.1.0-SNAPSHOT../pom.xml
diff --git a/open-banking-accelerator/accelerators/pom.xml b/open-banking-accelerator/accelerators/pom.xml
index b51f03f1..0fff04ac 100644
--- a/open-banking-accelerator/accelerators/pom.xml
+++ b/open-banking-accelerator/accelerators/pom.xml
@@ -23,7 +23,7 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.1.0
+ 3.1.0-SNAPSHOT../../pom.xml
diff --git a/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml b/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml
index 9fedd7e2..e890b38a 100644
--- a/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml
+++ b/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml
@@ -19,7 +19,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.ciba/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.ciba/pom.xml
index cdfe4b74..67977c13 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.ciba/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.ciba/pom.xml
@@ -25,7 +25,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../pom.xmlcom.wso2.openbanking.accelerator.ciba
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
index 1faab072..2d84a011 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
@@ -25,7 +25,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml
index 7283cdf2..bbdc8cc2 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml
@@ -25,7 +25,7 @@
com.wso2.openbanking.accelerator.data.publishercom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
index 048643c1..ae6033ba 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml
index 8ac8bf7b..766611c2 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
index 59b562cb..c826daea 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
@@ -25,7 +25,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml
index 978850c5..ea2e3632 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml
index 9d5319cf..0adfa797 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml
index 3304ba11..b9aef3c4 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml
@@ -22,7 +22,7 @@
com.wso2.openbanking.accelerator.runtimecom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml
index 7ac8f3bb..a9c44514 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml
index 1ceb2488..fde29671 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../pom.xml
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml
index 37e9dfc1..32733ffc 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml
@@ -24,7 +24,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../../pom.xml
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
index ab07daa4..35357bea 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml
index e6089c41..cfb00b16 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml
index afdb277a..ff8f9197 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml
@@ -19,7 +19,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml
index 002d5000..f4987dcd 100644
--- a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml
+++ b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml
index 8c4c023c..0c53985f 100644
--- a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml
+++ b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml
index 40b9c67e..cc3e67bb 100755
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml
index d8e0751b..ed3f5111 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml
@@ -18,7 +18,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml
index 37e6b8cf..ba795904 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml
@@ -25,7 +25,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../../pom.xml
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
index 0d6043e1..35b937f0 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml
index 20c5ca2b..5dad559e 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demosite.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demosite.endpoint/pom.xml
index 0e01e9b9..cee764ee 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demosite.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demosite.endpoint/pom.xml
@@ -22,7 +22,7 @@
open-bankingcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml
index 18a90ac6..7520d9d3 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml
@@ -19,7 +19,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml
index 54cc7383..b7577803 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml
@@ -25,7 +25,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../../pom.xml
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml
index ab4a56b8..b4fa5978 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/pom.xml b/open-banking-accelerator/pom.xml
index a7179e8f..7cd39601 100644
--- a/open-banking-accelerator/pom.xml
+++ b/open-banking-accelerator/pom.xml
@@ -25,14 +25,14 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.1.0
+ 3.1.0-SNAPSHOT../pom.xmlWSO2 Open Banking Acceleratoropen-banking-acceleratorpom
- 3.1.0
+ 3.1.0-SNAPSHOTcomponents/com.wso2.openbanking.accelerator.common
diff --git a/open-banking-react-apps/bfsi-apps/consent-approval-ui/pom.xml b/open-banking-react-apps/bfsi-apps/consent-approval-ui/pom.xml
index 96109e3d..ddb7561e 100644
--- a/open-banking-react-apps/bfsi-apps/consent-approval-ui/pom.xml
+++ b/open-banking-react-apps/bfsi-apps/consent-approval-ui/pom.xml
@@ -24,7 +24,7 @@
com.wso2.openbanking.acceleratoropen-banking-react-apps
- 3.1.0
+ 3.1.0-SNAPSHOT../../pom.xml
diff --git a/open-banking-react-apps/bfsi-apps/consent-manager-dashboard/pom.xml b/open-banking-react-apps/bfsi-apps/consent-manager-dashboard/pom.xml
index 326b656e..830a3fde 100644
--- a/open-banking-react-apps/bfsi-apps/consent-manager-dashboard/pom.xml
+++ b/open-banking-react-apps/bfsi-apps/consent-manager-dashboard/pom.xml
@@ -24,7 +24,7 @@
com.wso2.openbanking.acceleratoropen-banking-react-apps
- 3.1.0
+ 3.1.0-SNAPSHOT../../pom.xml
diff --git a/open-banking-react-apps/bfsi-bff/pom.xml b/open-banking-react-apps/bfsi-bff/pom.xml
index 8a9f5fb3..9c201d02 100644
--- a/open-banking-react-apps/bfsi-bff/pom.xml
+++ b/open-banking-react-apps/bfsi-bff/pom.xml
@@ -24,7 +24,7 @@
com.wso2.openbanking.acceleratoropen-banking-react-apps
- 3.1.0
+ 3.1.0-SNAPSHOT../pom.xml
diff --git a/open-banking-react-apps/pom.xml b/open-banking-react-apps/pom.xml
index d894c92c..8d3147d4 100644
--- a/open-banking-react-apps/pom.xml
+++ b/open-banking-react-apps/pom.xml
@@ -25,7 +25,7 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.1.0
+ 3.1.0-SNAPSHOT../pom.xml
diff --git a/open-banking-sample-toolkit/components/aggregator-gateway/pom.xml b/open-banking-sample-toolkit/components/aggregator-gateway/pom.xml
index d03f4da5..e4dae8db 100644
--- a/open-banking-sample-toolkit/components/aggregator-gateway/pom.xml
+++ b/open-banking-sample-toolkit/components/aggregator-gateway/pom.xml
@@ -21,7 +21,7 @@
open-banking-sample-toolkitcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../pom.xmlcom.wso2.openbanking.sample.aggregator.gateway
diff --git a/open-banking-sample-toolkit/components/aggregator-identity/pom.xml b/open-banking-sample-toolkit/components/aggregator-identity/pom.xml
index 8d6e1b95..48e3da6f 100644
--- a/open-banking-sample-toolkit/components/aggregator-identity/pom.xml
+++ b/open-banking-sample-toolkit/components/aggregator-identity/pom.xml
@@ -22,7 +22,7 @@
open-banking-sample-toolkitcom.wso2.openbanking.accelerator
- 3.1.0
+ 3.1.0-SNAPSHOT../../pom.xmlcom.wso2.openbanking.sample.aggregator.identity
diff --git a/open-banking-sample-toolkit/pom.xml b/open-banking-sample-toolkit/pom.xml
index 42abb661..6d9fba6c 100644
--- a/open-banking-sample-toolkit/pom.xml
+++ b/open-banking-sample-toolkit/pom.xml
@@ -22,7 +22,7 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.1.0
+ 3.1.0-SNAPSHOT../pom.xmlopen-banking-sample-toolkit
diff --git a/react-apps/pom.xml b/react-apps/pom.xml
index 36db0e70..d226717e 100644
--- a/react-apps/pom.xml
+++ b/react-apps/pom.xml
@@ -24,7 +24,7 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.1.0
+ 3.1.0-SNAPSHOT../pom.xml
diff --git a/react-apps/self-care-portal/pom.xml b/react-apps/self-care-portal/pom.xml
index 70997838..ae7adb65 100644
--- a/react-apps/self-care-portal/pom.xml
+++ b/react-apps/self-care-portal/pom.xml
@@ -25,7 +25,7 @@
com.wso2.openbanking.acceleratorreact-apps
- 3.1.0
+ 3.1.0-SNAPSHOT../pom.xml
From 3079fa21345290540194f55187778dd6e167eb9d Mon Sep 17 00:00:00 2001
From: imesh94
Date: Thu, 17 Aug 2023 16:16:58 +0530
Subject: [PATCH 006/281] Add a method to get redirect_uri using par
request_uri
---
.../OBIdentifierAuthenticator.java | 49 +++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/authenticator/OBIdentifierAuthenticator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/authenticator/OBIdentifierAuthenticator.java
index 1710f41d..645e2fc3 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/authenticator/OBIdentifierAuthenticator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/authenticator/OBIdentifierAuthenticator.java
@@ -515,6 +515,24 @@ private void appendRedirectUri(JSONObject sessionData) throws OpenBankingExcepti
}
}
+ /**
+ * Get redirect_uri using request_uri.
+ *
+ * @param requestUri - request_uri
+ * @return redirect_uri
+ * @throws OpenBankingException - OpenBankingException
+ */
+ public String getRedirectUri(String requestUri) throws OpenBankingException {
+
+ JSONObject requestObjectVal = getParRequestObject(requestUri);
+ if (requestObjectVal.has(REDIRECT_URI)) {
+ return requestObjectVal.get(REDIRECT_URI).toString();
+ } else {
+ log.error("redirect_uri could not be found in the par request object.");
+ throw new OpenBankingException("redirect_uri could not be found in the par request object.");
+ }
+ }
+
/**
* Retrieve PAR request object from session data cache.
*
@@ -548,6 +566,37 @@ private JSONObject getParRequestObject(JSONObject sessionData) throws OpenBankin
}
}
+ /**
+ * Retrieve PAR request object from request_uri.
+ *
+ * @param requestUri - request_uri
+ * @return Request object json.
+ * @throws OpenBankingException - OpenBankingException
+ */
+ @Generated(message = "Excluding from code coverage since it requires a valid cache entry")
+ private JSONObject getParRequestObject(String requestUri) throws OpenBankingException {
+
+ String[] requestUriArr = requestUri.split(":");
+ String requestUriRef = requestUriArr[requestUriArr.length - 1];
+ SessionDataCacheKey cacheKey = new SessionDataCacheKey(requestUriRef);
+ SessionDataCacheEntry cacheEntry = SessionDataCache.getInstance().getValueFromCache(cacheKey);
+
+ if (cacheEntry != null) {
+ String essentialClaims = cacheEntry.getoAuth2Parameters().getEssentialClaims();
+ byte[] requestObject;
+ try {
+ requestObject = Base64.getDecoder().decode(essentialClaims.split("\\.")[1]);
+ } catch (IllegalArgumentException e) {
+ // Decode if the requestObject is base64-url encoded.
+ requestObject = Base64.getUrlDecoder().decode(essentialClaims.split("\\.")[1]);
+ }
+ return new JSONObject(new String(requestObject, StandardCharsets.UTF_8));
+ } else {
+ log.error("Could not able to fetch par request object from session data cache.");
+ throw new OpenBankingException("Could not able to fetch par request object from session data cache.");
+ }
+ }
+
/**
* Get SSA client_name using clientId.
*
From f3ae7bbad9df41808633f167066fc09a0686d556 Mon Sep 17 00:00:00 2001
From: imesh94
Date: Mon, 21 Aug 2023 12:50:40 +0530
Subject: [PATCH 007/281] Add request object retrieval to a common method
---
.../OBIdentifierAuthenticator.java | 41 ++++++++-----------
1 file changed, 18 insertions(+), 23 deletions(-)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/authenticator/OBIdentifierAuthenticator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/authenticator/OBIdentifierAuthenticator.java
index 645e2fc3..7d5437d3 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/authenticator/OBIdentifierAuthenticator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/authenticator/OBIdentifierAuthenticator.java
@@ -544,26 +544,8 @@ public String getRedirectUri(String requestUri) throws OpenBankingException {
private JSONObject getParRequestObject(JSONObject sessionData) throws OpenBankingException {
//get request ref Ex -> "IVL...." from "urn::IVL..."
- String[] requestUri = sessionData.get(REQUEST_URI).toString().split(":");
- String requestUriRef = requestUri[requestUri.length - 1];
-
- SessionDataCacheKey cacheKey = new SessionDataCacheKey(requestUriRef);
- SessionDataCacheEntry cacheEntry = SessionDataCache.getInstance().getValueFromCache(cacheKey);
-
- if (cacheEntry != null) {
- String essentialClaims = cacheEntry.getoAuth2Parameters().getEssentialClaims();
- byte[] requestObject;
- try {
- requestObject = Base64.getDecoder().decode(essentialClaims.split("\\.")[1]);
- } catch (IllegalArgumentException e) {
- // Decode if the requestObject is base64-url encoded.
- requestObject = Base64.getUrlDecoder().decode(essentialClaims.split("\\.")[1]);
- }
- return new JSONObject(new String(requestObject, StandardCharsets.UTF_8));
- } else {
- log.error("Could not able to fetch par request object from session data cache.");
- throw new OpenBankingException("Could not able to fetch par request object from session data cache.");
- }
+ String requestUri = sessionData.get(REQUEST_URI).toString();
+ return getParRequestObject(requestUri);
}
/**
@@ -578,7 +560,20 @@ private JSONObject getParRequestObject(String requestUri) throws OpenBankingExce
String[] requestUriArr = requestUri.split(":");
String requestUriRef = requestUriArr[requestUriArr.length - 1];
- SessionDataCacheKey cacheKey = new SessionDataCacheKey(requestUriRef);
+ return getRequestObjectUsingUriReference(requestUriRef);
+ }
+
+ /**
+ * Retrieve PAR request object using request_uri reference.
+ *
+ * @param requestUriReference - request_uri reference (i.e:last part of request_uri split by :)
+ * @return Request object json.
+ * @throws OpenBankingException - OpenBankingException
+ */
+ @Generated(message = "Excluding from code coverage since it requires a valid cache entry")
+ private JSONObject getRequestObjectUsingUriReference(String requestUriReference) throws OpenBankingException {
+
+ SessionDataCacheKey cacheKey = new SessionDataCacheKey(requestUriReference);
SessionDataCacheEntry cacheEntry = SessionDataCache.getInstance().getValueFromCache(cacheKey);
if (cacheEntry != null) {
@@ -592,8 +587,8 @@ private JSONObject getParRequestObject(String requestUri) throws OpenBankingExce
}
return new JSONObject(new String(requestObject, StandardCharsets.UTF_8));
} else {
- log.error("Could not able to fetch par request object from session data cache.");
- throw new OpenBankingException("Could not able to fetch par request object from session data cache.");
+ log.error("Unable to fetch par request object from session data cache.");
+ throw new OpenBankingException("Unable to fetch par request object from session data cache.");
}
}
From f4751de94803b8f84cc833957b06264043818cd2 Mon Sep 17 00:00:00 2001
From: imesh94
Date: Mon, 2 Oct 2023 20:30:17 +0530
Subject: [PATCH 008/281] Fix code coverage issue
---
.../identity/authenticator/OBIdentifierAuthenticator.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/authenticator/OBIdentifierAuthenticator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/authenticator/OBIdentifierAuthenticator.java
index 7d5437d3..4eb4682d 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/authenticator/OBIdentifierAuthenticator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/authenticator/OBIdentifierAuthenticator.java
@@ -522,6 +522,7 @@ private void appendRedirectUri(JSONObject sessionData) throws OpenBankingExcepti
* @return redirect_uri
* @throws OpenBankingException - OpenBankingException
*/
+ @Generated(message = "Excluding from code coverage since it requires a valid cache entry")
public String getRedirectUri(String requestUri) throws OpenBankingException {
JSONObject requestObjectVal = getParRequestObject(requestUri);
From 3c888ea73387034543d1d986b0d67ff32c3c02e4 Mon Sep 17 00:00:00 2001
From: DedunuKarunarathne
<46235093+DedunuKarunarathne@users.noreply.github.com>
Date: Wed, 1 Nov 2023 13:18:42 +0530
Subject: [PATCH 009/281] update the version to 3.2.0-SNAPSHOT
---
open-banking-accelerator/accelerators/ob-apim/pom.xml | 2 +-
open-banking-accelerator/accelerators/ob-bi/pom.xml | 2 +-
.../com.wso2/openbanking-application-info-endpoint/pom.xml | 2 +-
.../maven/com.wso2/openbanking-consent-endpoint/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml | 2 +-
.../com.wso2.openbanking.authentication.webapp/pom.xml | 2 +-
open-banking-accelerator/accelerators/ob-is/pom.xml | 2 +-
open-banking-accelerator/accelerators/pom.xml | 2 +-
.../pom.xml | 2 +-
.../components/com.wso2.openbanking.accelerator.ciba/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.common/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.data.publisher/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.gateway/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.identity/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.keymanager/pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.runtime/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.throttler.dao/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.consent.endpoint/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.demo.backend/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.authentication.webapp/pom.xml | 2 +-
open-banking-accelerator/pom.xml | 4 ++--
open-banking-react-apps/bfsi-apps/consent-approval-ui/pom.xml | 2 +-
.../bfsi-apps/consent-manager-dashboard/pom.xml | 2 +-
open-banking-react-apps/bfsi-bff/pom.xml | 2 +-
open-banking-react-apps/pom.xml | 2 +-
.../components/aggregator-gateway/pom.xml | 2 +-
.../components/aggregator-identity/pom.xml | 2 +-
open-banking-sample-toolkit/pom.xml | 2 +-
pom.xml | 2 +-
react-apps/pom.xml | 2 +-
react-apps/self-care-portal/pom.xml | 2 +-
46 files changed, 47 insertions(+), 47 deletions(-)
diff --git a/open-banking-accelerator/accelerators/ob-apim/pom.xml b/open-banking-accelerator/accelerators/ob-apim/pom.xml
index c246b9d0..d2cf9ab9 100644
--- a/open-banking-accelerator/accelerators/ob-apim/pom.xml
+++ b/open-banking-accelerator/accelerators/ob-apim/pom.xml
@@ -25,7 +25,7 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../pom.xml
diff --git a/open-banking-accelerator/accelerators/ob-bi/pom.xml b/open-banking-accelerator/accelerators/ob-bi/pom.xml
index da0a5d37..98bd09f8 100644
--- a/open-banking-accelerator/accelerators/ob-bi/pom.xml
+++ b/open-banking-accelerator/accelerators/ob-bi/pom.xml
@@ -25,7 +25,7 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../pom.xml
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#application/META-INF/maven/com.wso2/openbanking-application-info-endpoint/pom.xml b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#application/META-INF/maven/com.wso2/openbanking-application-info-endpoint/pom.xml
index cc3e67bb..3fbb955c 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#application/META-INF/maven/com.wso2/openbanking-application-info-endpoint/pom.xml
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#application/META-INF/maven/com.wso2/openbanking-application-info-endpoint/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#consent/META-INF/maven/com.wso2/openbanking-consent-endpoint/pom.xml b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#consent/META-INF/maven/com.wso2/openbanking-consent-endpoint/pom.xml
index ba795904..80248e96 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#consent/META-INF/maven/com.wso2/openbanking-consent-endpoint/pom.xml
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#consent/META-INF/maven/com.wso2/openbanking-consent-endpoint/pom.xml
@@ -25,7 +25,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../../pom.xml
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#dynamic-client-registration/META-INF/maven/com.wso2/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#dynamic-client-registration/META-INF/maven/com.wso2/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
index 35b937f0..576a7cea 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#dynamic-client-registration/META-INF/maven/com.wso2/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/api#openbanking#dynamic-client-registration/META-INF/maven/com.wso2/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/ob#authenticationendpoint/META-INF/maven/com.wso2/com.wso2.openbanking.authentication.webapp/pom.xml b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/ob#authenticationendpoint/META-INF/maven/com.wso2/com.wso2.openbanking.authentication.webapp/pom.xml
index b4fa5978..2218c8b3 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/ob#authenticationendpoint/META-INF/maven/com.wso2/com.wso2.openbanking.authentication.webapp/pom.xml
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/deployment/server/webapps/ob#authenticationendpoint/META-INF/maven/com.wso2/com.wso2.openbanking.authentication.webapp/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/accelerators/ob-is/pom.xml b/open-banking-accelerator/accelerators/ob-is/pom.xml
index 201cb569..c8ec0e13 100644
--- a/open-banking-accelerator/accelerators/ob-is/pom.xml
+++ b/open-banking-accelerator/accelerators/ob-is/pom.xml
@@ -25,7 +25,7 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../pom.xml
diff --git a/open-banking-accelerator/accelerators/pom.xml b/open-banking-accelerator/accelerators/pom.xml
index 0fff04ac..4064fe5d 100644
--- a/open-banking-accelerator/accelerators/pom.xml
+++ b/open-banking-accelerator/accelerators/pom.xml
@@ -23,7 +23,7 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../pom.xml
diff --git a/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml b/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml
index e890b38a..03bceb87 100644
--- a/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml
+++ b/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml
@@ -19,7 +19,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.ciba/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.ciba/pom.xml
index 67977c13..3e35d80f 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.ciba/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.ciba/pom.xml
@@ -25,7 +25,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../pom.xmlcom.wso2.openbanking.accelerator.ciba
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
index 2d84a011..1b417e52 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
@@ -25,7 +25,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml
index bbdc8cc2..12c8b6c0 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml
@@ -25,7 +25,7 @@
com.wso2.openbanking.accelerator.data.publishercom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
index ae6033ba..6acfecf3 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml
index 766611c2..d367f077 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
index c826daea..c4a8b9bb 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
@@ -25,7 +25,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml
index ea2e3632..0b2e3e5d 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml
index 0adfa797..909246c1 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml
index b9aef3c4..36f4b193 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml
@@ -22,7 +22,7 @@
com.wso2.openbanking.accelerator.runtimecom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml
index a9c44514..75be5543 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml
index fde29671..c7e11427 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../pom.xml
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml
index 32733ffc..ddb2df0b 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml
@@ -24,7 +24,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../../pom.xml
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
index 35357bea..33e724c8 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml
index cfb00b16..029fce11 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml
index ff8f9197..75655e64 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml
@@ -19,7 +19,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml
index f4987dcd..13fb7f64 100644
--- a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml
+++ b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml
index 0c53985f..d02d7c8d 100644
--- a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml
+++ b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml
index cc3e67bb..3fbb955c 100755
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml
index ed3f5111..57603425 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml
@@ -18,7 +18,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml
index ba795904..80248e96 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml
@@ -25,7 +25,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../../pom.xml
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
index 35b937f0..576a7cea 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml
index 5dad559e..a46cac2b 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demosite.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demosite.endpoint/pom.xml
index cee764ee..24cf3bb7 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demosite.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demosite.endpoint/pom.xml
@@ -22,7 +22,7 @@
open-bankingcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml
index 7520d9d3..2a601530 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml
@@ -19,7 +19,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml
index b7577803..bc4e2173 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml
@@ -25,7 +25,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../../pom.xml
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml
index b4fa5978..2218c8b3 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/pom.xml b/open-banking-accelerator/pom.xml
index 7cd39601..fbee0107 100644
--- a/open-banking-accelerator/pom.xml
+++ b/open-banking-accelerator/pom.xml
@@ -25,14 +25,14 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../pom.xmlWSO2 Open Banking Acceleratoropen-banking-acceleratorpom
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOTcomponents/com.wso2.openbanking.accelerator.common
diff --git a/open-banking-react-apps/bfsi-apps/consent-approval-ui/pom.xml b/open-banking-react-apps/bfsi-apps/consent-approval-ui/pom.xml
index ddb7561e..e9646437 100644
--- a/open-banking-react-apps/bfsi-apps/consent-approval-ui/pom.xml
+++ b/open-banking-react-apps/bfsi-apps/consent-approval-ui/pom.xml
@@ -24,7 +24,7 @@
com.wso2.openbanking.acceleratoropen-banking-react-apps
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../pom.xml
diff --git a/open-banking-react-apps/bfsi-apps/consent-manager-dashboard/pom.xml b/open-banking-react-apps/bfsi-apps/consent-manager-dashboard/pom.xml
index 830a3fde..353ee78a 100644
--- a/open-banking-react-apps/bfsi-apps/consent-manager-dashboard/pom.xml
+++ b/open-banking-react-apps/bfsi-apps/consent-manager-dashboard/pom.xml
@@ -24,7 +24,7 @@
com.wso2.openbanking.acceleratoropen-banking-react-apps
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../pom.xml
diff --git a/open-banking-react-apps/bfsi-bff/pom.xml b/open-banking-react-apps/bfsi-bff/pom.xml
index 9c201d02..4ba9084e 100644
--- a/open-banking-react-apps/bfsi-bff/pom.xml
+++ b/open-banking-react-apps/bfsi-bff/pom.xml
@@ -24,7 +24,7 @@
com.wso2.openbanking.acceleratoropen-banking-react-apps
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../pom.xml
diff --git a/open-banking-react-apps/pom.xml b/open-banking-react-apps/pom.xml
index 8d3147d4..f19762b1 100644
--- a/open-banking-react-apps/pom.xml
+++ b/open-banking-react-apps/pom.xml
@@ -25,7 +25,7 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../pom.xml
diff --git a/open-banking-sample-toolkit/components/aggregator-gateway/pom.xml b/open-banking-sample-toolkit/components/aggregator-gateway/pom.xml
index e4dae8db..a508f53d 100644
--- a/open-banking-sample-toolkit/components/aggregator-gateway/pom.xml
+++ b/open-banking-sample-toolkit/components/aggregator-gateway/pom.xml
@@ -21,7 +21,7 @@
open-banking-sample-toolkitcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../pom.xmlcom.wso2.openbanking.sample.aggregator.gateway
diff --git a/open-banking-sample-toolkit/components/aggregator-identity/pom.xml b/open-banking-sample-toolkit/components/aggregator-identity/pom.xml
index 48e3da6f..df1c7d45 100644
--- a/open-banking-sample-toolkit/components/aggregator-identity/pom.xml
+++ b/open-banking-sample-toolkit/components/aggregator-identity/pom.xml
@@ -22,7 +22,7 @@
open-banking-sample-toolkitcom.wso2.openbanking.accelerator
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../../pom.xmlcom.wso2.openbanking.sample.aggregator.identity
diff --git a/open-banking-sample-toolkit/pom.xml b/open-banking-sample-toolkit/pom.xml
index 6d9fba6c..8cbcb21b 100644
--- a/open-banking-sample-toolkit/pom.xml
+++ b/open-banking-sample-toolkit/pom.xml
@@ -22,7 +22,7 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../pom.xmlopen-banking-sample-toolkit
diff --git a/pom.xml b/pom.xml
index b43d9bcc..9479e7a6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,7 +21,7 @@
com.wso2.openbanking.acceleratoropen-bankingpom
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOTorg.wso2
diff --git a/react-apps/pom.xml b/react-apps/pom.xml
index d226717e..737f309a 100644
--- a/react-apps/pom.xml
+++ b/react-apps/pom.xml
@@ -24,7 +24,7 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../pom.xml
diff --git a/react-apps/self-care-portal/pom.xml b/react-apps/self-care-portal/pom.xml
index ae7adb65..edce496d 100644
--- a/react-apps/self-care-portal/pom.xml
+++ b/react-apps/self-care-portal/pom.xml
@@ -25,7 +25,7 @@
com.wso2.openbanking.acceleratorreact-apps
- 3.1.0-SNAPSHOT
+ 3.2.0-SNAPSHOT../pom.xml
From 7387034d3e8299dce68bbc5b1eb9687b88ac578f Mon Sep 17 00:00:00 2001
From: Ashirwada
Date: Thu, 2 Nov 2023 11:20:16 +0530
Subject: [PATCH 010/281] Fixing issues in Event Notification Implementation
---
.../event-notifications/mssql.sql | 43 +++++++++++++
.../event-notifications/mysql.sql | 50 ++++++++++++++++
.../event-notifications/oracle.sql | 56 +++++++++++++++++
.../event-notifications/postgresql.sql | 44 ++++++++++++++
.../dao/EventSubscriptionSqlStatements.java | 26 ++++----
.../DefaultEventPollingServiceHandler.java | 4 +-
...efaultEventSubscriptionServiceHandler.java | 34 +++++------
.../endpoint/api/EventPollingEndpoint.java | 60 ++++++++++---------
.../EventNotificationEndPointConstants.java | 1 +
.../endpoint/util/EventNotificationUtils.java | 27 +++++++--
.../endpoint/util/EventSubscriptionUtils.java | 12 ++--
11 files changed, 289 insertions(+), 68 deletions(-)
create mode 100644 open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/mssql.sql
create mode 100644 open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/mysql.sql
create mode 100644 open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/oracle.sql
create mode 100644 open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/postgresql.sql
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/mssql.sql b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/mssql.sql
new file mode 100644
index 00000000..6419446c
--- /dev/null
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/mssql.sql
@@ -0,0 +1,43 @@
+CREATE TABLE OB_NOTIFICATION (
+ NOTIFICATION_ID varchar(36) NOT NULL,
+ CLIENT_ID varchar(255) NOT NULL,
+ RESOURCE_ID varchar(255) NOT NULL,
+ STATUS varchar(10) NOT NULL,
+ UPDATED_TIMESTAMP DATETIME2(0) DEFAULT GETDATE(),
+ PRIMARY KEY (NOTIFICATION_ID)
+);
+
+CREATE TABLE OB_NOTIFICATION_EVENT (
+ EVENT_ID int NOT NULL IDENTITY,
+ NOTIFICATION_ID varchar(36) NOT NULL,
+ EVENT_TYPE varchar(200) NOT NULL,
+ EVENT_INFO varchar(1000) NOT NULL,
+ PRIMARY KEY (EVENT_ID),
+ CONSTRAINT FK_NotificationEvent FOREIGN KEY (NOTIFICATION_ID) REFERENCES OB_NOTIFICATION(NOTIFICATION_ID)
+);
+
+CREATE TABLE OB_NOTIFICATION_ERROR (
+ NOTIFICATION_ID varchar(36) NOT NULL,
+ ERROR_CODE varchar(255) NOT NULL,
+ DESCRIPTION varchar(255) NOT NULL,
+ PRIMARY KEY (NOTIFICATION_ID),
+ CONSTRAINT FK_NotificationError FOREIGN KEY (NOTIFICATION_ID) REFERENCES OB_NOTIFICATION(NOTIFICATION_ID)
+);
+
+CREATE TABLE OB_NOTIFICATION_SUBSCRIPTION (
+ SUBSCRIPTION_ID varchar(36) NOT NULL,
+ CLIENT_ID varchar(255) NOT NULL,
+ REQUEST JSON NOT NULL,
+ CALLBACK_URL varchar(255),
+ TIMESTAMP BIGINT NOT NULL,
+ SPEC_VERSION varchar(255),
+ STATUS varchar(255) NOT NULL,
+ PRIMARY KEY (SUBSCRIPTION_ID)
+);
+
+CREATE TABLE OB_NOTIFICATION_SUBSCRIBED_EVENTS (
+ SUBSCRIPTION_ID varchar(36) NOT NULL,
+ EVENT_TYPE varchar(255) NOT NULL,
+ PRIMARY KEY (SUBSCRIPTION_ID, EVENT_TYPE),
+ CONSTRAINT FK_NotificationSubEvents FOREIGN KEY (SUBSCRIPTION_ID) REFERENCES OB_NOTIFICATION_SUBSCRIPTION(SUBSCRIPTION_ID)
+);
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/mysql.sql b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/mysql.sql
new file mode 100644
index 00000000..fbbfa516
--- /dev/null
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/mysql.sql
@@ -0,0 +1,50 @@
+-- For event notifications feature run the following queries against the openbank_openbankingdb--
+
+CREATE TABLE IF NOT EXISTS OB_NOTIFICATION (
+ NOTIFICATION_ID varchar(36) NOT NULL,
+ CLIENT_ID varchar(255) NOT NULL,
+ RESOURCE_ID varchar(255) NOT NULL,
+ STATUS varchar(10) NOT NULL,
+ UPDATED_TIMESTAMP TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ PRIMARY KEY (NOTIFICATION_ID)
+)
+ENGINE=InnoDB;
+
+CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_EVENT (
+ EVENT_ID int(11) NOT NULL AUTO_INCREMENT,
+ NOTIFICATION_ID varchar(36) NOT NULL,
+ EVENT_TYPE varchar(200) NOT NULL,
+ EVENT_INFO varchar(1000) NOT NULL,
+ PRIMARY KEY (EVENT_ID),
+ CONSTRAINT FK_NotificationEvent FOREIGN KEY (NOTIFICATION_ID) REFERENCES OB_NOTIFICATION(NOTIFICATION_ID)
+)
+ENGINE=InnoDB;
+
+CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_ERROR (
+ NOTIFICATION_ID varchar(36) NOT NULL,
+ ERROR_CODE varchar(255) NOT NULL,
+ DESCRIPTION varchar(255) NOT NULL,
+ PRIMARY KEY (NOTIFICATION_ID),
+ CONSTRAINT FK_NotificationError FOREIGN KEY (NOTIFICATION_ID) REFERENCES OB_NOTIFICATION(NOTIFICATION_ID)
+)
+ENGINE=InnoDB;
+
+CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_SUBSCRIPTION (
+ SUBSCRIPTION_ID varchar(36) NOT NULL,
+ CLIENT_ID varchar(255) NOT NULL,
+ REQUEST JSON NOT NULL,
+ CALLBACK_URL varchar(255),
+ TIMESTAMP BIGINT NOT NULL,
+ SPEC_VERSION varchar(255),
+ STATUS varchar(255) NOT NULL,
+ PRIMARY KEY (SUBSCRIPTION_ID)
+)
+ENGINE=InnoDB;
+
+CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_SUBSCRIBED_EVENTS (
+ SUBSCRIPTION_ID varchar(36) NOT NULL,
+ EVENT_TYPE varchar(255) NOT NULL,
+ PRIMARY KEY (SUBSCRIPTION_ID, EVENT_TYPE),
+ CONSTRAINT FK_NotificationSubEvents FOREIGN KEY (SUBSCRIPTION_ID) REFERENCES OB_NOTIFICATION_SUBSCRIPTION(SUBSCRIPTION_ID)
+)
+ENGINE=InnoDB;
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/oracle.sql b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/oracle.sql
new file mode 100644
index 00000000..176c0d97
--- /dev/null
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/oracle.sql
@@ -0,0 +1,56 @@
+CREATE TABLE OB_NOTIFICATION (
+ NOTIFICATION_ID varchar2(36) NOT NULL,
+ CLIENT_ID varchar2(255) NOT NULL,
+ RESOURCE_ID varchar2(255) NOT NULL,
+ STATUS varchar2(10) NOT NULL,
+ UPDATED_TIMESTAMP TIMESTAMP(0) DEFAULT SYSTIMESTAMP,
+ PRIMARY KEY (NOTIFICATION_ID)
+);
+
+CREATE TABLE OB_NOTIFICATION_EVENT (
+ EVENT_ID number(10) NOT NULL,
+ NOTIFICATION_ID varchar2(36) NOT NULL,
+ EVENT_TYPE varchar2(200) NOT NULL,
+ EVENT_INFO varchar2(1000) NOT NULL,
+ PRIMARY KEY (EVENT_ID),
+ CONSTRAINT FK_NotificationEvent FOREIGN KEY (NOTIFICATION_ID) REFERENCES OB_NOTIFICATION(NOTIFICATION_ID)
+);
+
+-- Generate ID using sequence and trigger
+CREATE SEQUENCE OB_NOTIFICATION_EVENT_seq START WITH 1 INCREMENT BY 1;
+
+CREATE OR REPLACE TRIGGER OB_NOTIFICATION_EVENT_seq_tr
+ BEFORE INSERT ON OB_NOTIFICATION_EVENT FOR EACH ROW
+ WHEN (NEW.EVENT_ID IS NULL)
+BEGIN
+ SELECT OB_NOTIFICATION_EVENT_seq.NEXTVAL INTO :NEW.EVENT_ID FROM DUAL;
+END;
+
+
+CREATE TABLE OB_NOTIFICATION_ERROR (
+ NOTIFICATION_ID varchar2(36) NOT NULL,
+ ERROR_CODE varchar2(255) NOT NULL,
+ DESCRIPTION varchar2(255) NOT NULL,
+ PRIMARY KEY (NOTIFICATION_ID),
+ CONSTRAINT FK_NotificationError FOREIGN KEY (NOTIFICATION_ID) REFERENCES OB_NOTIFICATION(NOTIFICATION_ID)
+)
+
+CREATE TABLE OB_NOTIFICATION_SUBSCRIPTION (
+ SUBSCRIPTION_ID varchar(36) NOT NULL,
+ CLIENT_ID varchar(255) NOT NULL,
+ REQUEST JSON NOT NULL,
+ CALLBACK_URL varchar(255),
+ TIMESTAMP BIGINT NOT NULL,
+ SPEC_VERSION varchar(255),
+ STATUS varchar(255) NOT NULL,
+ PRIMARY KEY (SUBSCRIPTION_ID)
+);
+
+CREATE TABLE OB_NOTIFICATION_SUBSCRIBED_EVENTS (
+ SUBSCRIPTION_ID varchar(36) NOT NULL,
+ EVENT_TYPE varchar(255) NOT NULL,
+ PRIMARY KEY (SUBSCRIPTION_ID, EVENT_TYPE),
+ CONSTRAINT FK_NotificationSubEvents FOREIGN KEY (SUBSCRIPTION_ID) REFERENCES OB_NOTIFICATION_SUBSCRIPTION(SUBSCRIPTION_ID)
+);
+
+
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/postgresql.sql b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/postgresql.sql
new file mode 100644
index 00000000..971e6487
--- /dev/null
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/postgresql.sql
@@ -0,0 +1,44 @@
+-- For event notifications feature run the following queries against the openbank_openbankingdb--
+
+CREATE TABLE IF NOT EXISTS OB_NOTIFICATION (
+ NOTIFICATION_ID varchar(36) NOT NULL,
+ CLIENT_ID varchar(255) NOT NULL,
+ RESOURCE_ID varchar(255) NOT NULL,
+ STATUS varchar(10) NOT NULL,
+ UPDATED_TIMESTAMP TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (NOTIFICATION_ID)
+);
+
+CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_EVENT (
+ EVENT_ID SERIAL PRIMARY KEY,
+ NOTIFICATION_ID varchar(36) NOT NULL,
+ EVENT_TYPE varchar(200) NOT NULL,
+ EVENT_INFO varchar(1000) NOT NULL,
+ CONSTRAINT FK_NotificationEvent FOREIGN KEY (NOTIFICATION_ID) REFERENCES OB_NOTIFICATION(NOTIFICATION_ID)
+);
+
+CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_ERROR (
+ NOTIFICATION_ID varchar(36) NOT NULL,
+ ERROR_CODE varchar(255) NOT NULL,
+ DESCRIPTION varchar(255) NOT NULL,
+ PRIMARY KEY (NOTIFICATION_ID),
+ CONSTRAINT FK_NotificationError FOREIGN KEY (NOTIFICATION_ID) REFERENCES OB_NOTIFICATION(NOTIFICATION_ID)
+);
+
+CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_SUBSCRIPTION (
+ SUBSCRIPTION_ID varchar(36) NOT NULL,
+ CLIENT_ID varchar(255) NOT NULL,
+ REQUEST JSON NOT NULL,
+ CALLBACK_URL varchar(255),
+ TIMESTAMP BIGINT NOT NULL,
+ SPEC_VERSION varchar(255),
+ STATUS varchar(255) NOT NULL,
+ PRIMARY KEY (SUBSCRIPTION_ID)
+);
+
+CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_SUBSCRIBED_EVENTS (
+ SUBSCRIPTION_ID varchar(36) NOT NULL,
+ EVENT_TYPE varchar(255) NOT NULL,
+ PRIMARY KEY (SUBSCRIPTION_ID, EVENT_TYPE),
+ CONSTRAINT FK_NotificationSubEvents FOREIGN KEY (SUBSCRIPTION_ID) REFERENCES OB_NOTIFICATION_SUBSCRIPTION(SUBSCRIPTION_ID)
+);
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/EventSubscriptionSqlStatements.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/EventSubscriptionSqlStatements.java
index 0e052546..855cbde9 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/EventSubscriptionSqlStatements.java
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/EventSubscriptionSqlStatements.java
@@ -24,48 +24,48 @@
public class EventSubscriptionSqlStatements {
public String storeEventSubscriptionQuery() {
- return "INSERT INTO NOTIFICATION_SUBSCRIPTION (SUBSCRIPTION_ID, CLIENT_ID, CALLBACK_URL, TIMESTAMP, " +
+ return "INSERT INTO OB_NOTIFICATION_SUBSCRIPTION (SUBSCRIPTION_ID, CLIENT_ID, CALLBACK_URL, TIMESTAMP, " +
"SPEC_VERSION, STATUS, REQUEST) VALUES (?,?,?,?,?,?,?)";
}
public String storeSubscribedEventTypesQuery() {
- return "INSERT INTO NOTIFICATION_SUBSCRIPTION_EVENTS (SUBSCRIPTION_ID, EVENT_TYPE) VALUES (?,?)";
+ return "INSERT INTO OB_NOTIFICATION_SUBSCRIBED_EVENTS (SUBSCRIPTION_ID, EVENT_TYPE) VALUES (?,?)";
}
public String getEventSubscriptionBySubscriptionIdQuery() {
return "SELECT ns.SUBSCRIPTION_ID, ns.CLIENT_ID, ns.REQUEST, ns.CALLBACK_URL, ns.TIMESTAMP, ns.SPEC_VERSION, " +
- "ns.STATUS, nse.EVENT_TYPE FROM NOTIFICATION_SUBSCRIPTION ns LEFT JOIN " +
- "NOTIFICATION_SUBSCRIPTION_EVENTS nse ON ns.SUBSCRIPTION_ID = nse.SUBSCRIPTION_ID WHERE " +
+ "ns.STATUS, nse.EVENT_TYPE FROM OB_NOTIFICATION_SUBSCRIPTION ns LEFT JOIN " +
+ "OB_NOTIFICATION_SUBSCRIBED_EVENTS nse ON ns.SUBSCRIPTION_ID = nse.SUBSCRIPTION_ID WHERE " +
"ns.SUBSCRIPTION_ID = ? AND ns.STATUS = 'CREATED'";
}
public String getEventSubscriptionsByClientIdQuery() {
return "SELECT ns.SUBSCRIPTION_ID, ns.CLIENT_ID, ns.REQUEST, ns.CALLBACK_URL, ns.TIMESTAMP, ns.SPEC_VERSION, " +
- "ns.STATUS, nse.EVENT_TYPE FROM NOTIFICATION_SUBSCRIPTION ns LEFT JOIN " +
- "NOTIFICATION_SUBSCRIPTION_EVENTS nse ON ns.SUBSCRIPTION_ID = nse.SUBSCRIPTION_ID WHERE " +
+ "ns.STATUS, nse.EVENT_TYPE FROM OB_NOTIFICATION_SUBSCRIPTION ns LEFT JOIN " +
+ "OB_NOTIFICATION_SUBSCRIBED_EVENTS nse ON ns.SUBSCRIPTION_ID = nse.SUBSCRIPTION_ID WHERE " +
"ns.CLIENT_ID = ? AND ns.STATUS = 'CREATED'";
}
public String getEventSubscriptionsByEventTypeQuery() {
return "SELECT ns.SUBSCRIPTION_ID, ns.CLIENT_ID, ns.REQUEST, ns.CALLBACK_URL, ns.TIMESTAMP, ns.SPEC_VERSION, " +
- "ns.STATUS, nse.EVENT_TYPE FROM NOTIFICATION_SUBSCRIPTION ns LEFT JOIN " +
- "NOTIFICATION_SUBSCRIPTION_EVENTS nse ON ns.SUBSCRIPTION_ID = nse.SUBSCRIPTION_ID WHERE " +
- "ns.SUBSCRIPTION_ID IN (SELECT ns.SUBSCRIPTION_ID FROM NOTIFICATION_SUBSCRIPTION ns LEFT " +
- "JOIN NOTIFICATION_SUBSCRIPTION_EVENTS nse ON ns.SUBSCRIPTION_ID = nse.SUBSCRIPTION_ID WHERE " +
+ "ns.STATUS, nse.EVENT_TYPE FROM OB_NOTIFICATION_SUBSCRIPTION ns LEFT JOIN " +
+ "OB_NOTIFICATION_SUBSCRIBED_EVENTS nse ON ns.SUBSCRIPTION_ID = nse.SUBSCRIPTION_ID WHERE " +
+ "ns.SUBSCRIPTION_ID IN (SELECT ns.SUBSCRIPTION_ID FROM OB_NOTIFICATION_SUBSCRIPTION ns LEFT " +
+ "JOIN OB_NOTIFICATION_SUBSCRIBED_EVENTS nse ON ns.SUBSCRIPTION_ID = nse.SUBSCRIPTION_ID WHERE " +
"nse.EVENT_TYPE = ? AND ns.STATUS = 'CREATED')";
}
public String updateEventSubscriptionQuery() {
- return "UPDATE NOTIFICATION_SUBSCRIPTION SET CALLBACK_URL = ?, TIMESTAMP = ?, REQUEST = ?" +
+ return "UPDATE OB_NOTIFICATION_SUBSCRIPTION SET CALLBACK_URL = ?, TIMESTAMP = ?, REQUEST = ?" +
"WHERE SUBSCRIPTION_ID = ?";
}
public String updateEventSubscriptionStatusQuery() {
- return "UPDATE NOTIFICATION_SUBSCRIPTION SET STATUS = ? WHERE SUBSCRIPTION_ID = ? && STATUS = 'CREATED'";
+ return "UPDATE OB_NOTIFICATION_SUBSCRIPTION SET STATUS = ? WHERE SUBSCRIPTION_ID = ? && STATUS = 'CREATED'";
}
public String deleteSubscribedEventTypesQuery() {
- return "DELETE FROM NOTIFICATION_SUBSCRIPTION_EVENTS WHERE SUBSCRIPTION_ID = ?";
+ return "DELETE FROM OB_NOTIFICATION_SUBSCRIBED_EVENTS WHERE SUBSCRIPTION_ID = ?";
}
}
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/DefaultEventPollingServiceHandler.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/DefaultEventPollingServiceHandler.java
index 063a2dca..c57dfd74 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/DefaultEventPollingServiceHandler.java
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/DefaultEventPollingServiceHandler.java
@@ -51,7 +51,7 @@ public void setEventPollingService(EventPollingService eventPollingService) {
/**
* This method is used to Poll Events as per request params.
- * @param eventPollingRequest
+ * @param eventPollingRequest JSON request for event polling
* @return
*/
public EventPollingResponse pollEvents(JSONObject eventPollingRequest) {
@@ -89,7 +89,7 @@ public EventPollingResponse pollEvents(JSONObject eventPollingRequest) {
/**
* This method will map the eventPollingRequest JSON to EventPollingDTO.
- * @param eventPollingRequest
+ * @param eventPollingRequest JSON request for event polling
* @return EventPollingDTO
*/
public EventPollingDTO mapPollingRequest(JSONObject eventPollingRequest) {
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/DefaultEventSubscriptionServiceHandler.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/DefaultEventSubscriptionServiceHandler.java
index 163f5dbb..406d2a64 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/DefaultEventSubscriptionServiceHandler.java
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/DefaultEventSubscriptionServiceHandler.java
@@ -28,7 +28,7 @@
import net.minidev.json.JSONObject;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.eclipse.jetty.http.HttpStatus;
+import org.springframework.http.HttpStatus;
import java.util.ArrayList;
import java.util.List;
@@ -65,13 +65,13 @@ public EventSubscriptionResponse createEventSubscription(EventSubscriptionDTO ev
try {
EventSubscription createEventSubscriptionResponse = eventSubscriptionService.
createEventSubscription(eventSubscription);
- eventSubscriptionResponse.setStatus(HttpStatus.CREATED_201);
+ eventSubscriptionResponse.setStatus(HttpStatus.CREATED.value());
eventSubscriptionResponse.
setResponseBody(mapSubscriptionModelToResponseJson(createEventSubscriptionResponse));
return eventSubscriptionResponse;
} catch (OBEventNotificationException e) {
log.error("Error occurred while creating event subscription", e);
- eventSubscriptionResponse.setStatus(HttpStatus.INTERNAL_SERVER_ERROR_500);
+ eventSubscriptionResponse.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
eventSubscriptionResponse.setErrorResponse(EventNotificationServiceUtil.getErrorDTO(
EventNotificationConstants.INVALID_REQUEST, e.getMessage()));
return eventSubscriptionResponse;
@@ -99,17 +99,17 @@ public EventSubscriptionResponse getEventSubscription(String clientId, String su
try {
EventSubscription eventSubscription = eventSubscriptionService.
getEventSubscriptionBySubscriptionId(subscriptionId);
- eventSubscriptionResponse.setStatus(HttpStatus.OK_200);
+ eventSubscriptionResponse.setStatus(HttpStatus.OK.value());
eventSubscriptionResponse.setResponseBody(mapSubscriptionModelToResponseJson(eventSubscription));
return eventSubscriptionResponse;
} catch (OBEventNotificationException e) {
log.error("Error occurred while retrieving event subscription", e);
if (e.getMessage().equals(EventNotificationConstants.EVENT_SUBSCRIPTION_NOT_FOUND)) {
- eventSubscriptionResponse.setStatus(HttpStatus.BAD_REQUEST_400);
+ eventSubscriptionResponse.setStatus(HttpStatus.BAD_REQUEST.value());
eventSubscriptionResponse.setErrorResponse(EventNotificationServiceUtil.getErrorDTO(
EventNotificationConstants.INVALID_REQUEST, e.getMessage()));
} else {
- eventSubscriptionResponse.setStatus(HttpStatus.INTERNAL_SERVER_ERROR_500);
+ eventSubscriptionResponse.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
eventSubscriptionResponse.setErrorResponse(EventNotificationServiceUtil.getErrorDTO(
EventNotificationConstants.INVALID_REQUEST, e.getMessage()));
}
@@ -139,12 +139,12 @@ public EventSubscriptionResponse getAllEventSubscriptions(String clientId) {
for (EventSubscription eventSubscription : eventSubscriptionList) {
eventSubscriptionResponseList.add(mapSubscriptionModelToResponseJson(eventSubscription));
}
- eventSubscriptionResponse.setStatus(HttpStatus.OK_200);
+ eventSubscriptionResponse.setStatus(HttpStatus.OK.value());
eventSubscriptionResponse.setResponseBody(eventSubscriptionResponseList);
return eventSubscriptionResponse;
} catch (OBEventNotificationException e) {
log.error("Error occurred while retrieving event subscriptions", e);
- eventSubscriptionResponse.setStatus(HttpStatus.INTERNAL_SERVER_ERROR_500);
+ eventSubscriptionResponse.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
eventSubscriptionResponse.setErrorResponse(EventNotificationServiceUtil.getErrorDTO(
EventNotificationConstants.INVALID_REQUEST, e.getMessage()));
return eventSubscriptionResponse;
@@ -175,12 +175,12 @@ public EventSubscriptionResponse getEventSubscriptionsByEventType(String clientI
for (EventSubscription eventSubscription : eventSubscriptionList) {
eventSubscriptionResponseList.add(mapSubscriptionModelToResponseJson(eventSubscription));
}
- eventSubscriptionResponse.setStatus(HttpStatus.OK_200);
+ eventSubscriptionResponse.setStatus(HttpStatus.OK.value());
eventSubscriptionResponse.setResponseBody(eventSubscriptionResponseList);
return eventSubscriptionResponse;
} catch (OBEventNotificationException e) {
log.error("Error occurred while retrieving event subscriptions", e);
- eventSubscriptionResponse.setStatus(HttpStatus.INTERNAL_SERVER_ERROR_500);
+ eventSubscriptionResponse.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
eventSubscriptionResponse.setErrorResponse(EventNotificationServiceUtil.getErrorDTO(
EventNotificationConstants.INVALID_REQUEST, e.getMessage()));
return eventSubscriptionResponse;
@@ -208,13 +208,13 @@ public EventSubscriptionResponse updateEventSubscription(EventSubscriptionDTO ev
try {
Boolean isUpdated = eventSubscriptionService.updateEventSubscription(eventSubscription);
if (!isUpdated) {
- eventSubscriptionResponse.setStatus(HttpStatus.BAD_REQUEST_400);
+ eventSubscriptionResponse.setStatus(HttpStatus.BAD_REQUEST.value());
eventSubscriptionResponse.setErrorResponse(EventNotificationServiceUtil.getErrorDTO(
EventNotificationConstants.INVALID_REQUEST,
"Event subscription not found."));
return eventSubscriptionResponse;
}
- eventSubscriptionResponse.setStatus(HttpStatus.OK_200);
+ eventSubscriptionResponse.setStatus(HttpStatus.OK.value());
EventSubscription eventSubscriptionUpdateResponse = eventSubscriptionService.
getEventSubscriptionBySubscriptionId(eventSubscriptionUpdateRequestDto.getSubscriptionId());
eventSubscriptionResponse.
@@ -222,7 +222,7 @@ public EventSubscriptionResponse updateEventSubscription(EventSubscriptionDTO ev
return eventSubscriptionResponse;
} catch (OBEventNotificationException e) {
log.error("Error occurred while updating event subscription", e);
- eventSubscriptionResponse.setStatus(HttpStatus.INTERNAL_SERVER_ERROR_500);
+ eventSubscriptionResponse.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
eventSubscriptionResponse.setErrorResponse(EventNotificationServiceUtil.getErrorDTO(
EventNotificationConstants.INVALID_REQUEST, e.getMessage()));
return eventSubscriptionResponse;
@@ -247,17 +247,17 @@ public EventSubscriptionResponse deleteEventSubscription(String clientId, String
try {
Boolean isDeleted = eventSubscriptionService.deleteEventSubscription(subscriptionId);
if (!isDeleted) {
- eventSubscriptionResponse.setStatus(HttpStatus.BAD_REQUEST_400);
+ eventSubscriptionResponse.setStatus(HttpStatus.BAD_REQUEST.value());
eventSubscriptionResponse.setErrorResponse(EventNotificationServiceUtil.getErrorDTO(
EventNotificationConstants.INVALID_REQUEST,
"Event subscription not found"));
return eventSubscriptionResponse;
}
- eventSubscriptionResponse.setStatus(HttpStatus.NO_CONTENT_204);
+ eventSubscriptionResponse.setStatus(HttpStatus.NO_CONTENT.value());
return eventSubscriptionResponse;
} catch (OBEventNotificationException e) {
log.error("Error occurred while deleting event subscription", e);
- eventSubscriptionResponse.setStatus(HttpStatus.INTERNAL_SERVER_ERROR_500);
+ eventSubscriptionResponse.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
eventSubscriptionResponse.setErrorResponse(EventNotificationServiceUtil.getErrorDTO(
EventNotificationConstants.INVALID_REQUEST, e.getMessage()));
return eventSubscriptionResponse;
@@ -277,7 +277,7 @@ private EventSubscriptionResponse validateClientId(String clientId) {
} catch (OBEventNotificationException e) {
log.error("Invalid client ID", e);
EventSubscriptionResponse eventSubscriptionResponse = new EventSubscriptionResponse();
- eventSubscriptionResponse.setStatus(HttpStatus.BAD_REQUEST_400);
+ eventSubscriptionResponse.setStatus(HttpStatus.BAD_REQUEST.value());
eventSubscriptionResponse.setErrorResponse(EventNotificationServiceUtil.getErrorDTO(
EventNotificationConstants.INVALID_REQUEST, e.getMessage()));
return eventSubscriptionResponse;
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/api/EventPollingEndpoint.java b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/api/EventPollingEndpoint.java
index 213a7316..dd39d1bf 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/api/EventPollingEndpoint.java
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/api/EventPollingEndpoint.java
@@ -83,37 +83,43 @@ public Response pollEvents(@Context HttpServletRequest request, @Context HttpSer
eventPollingData = parameterMap.get(EventNotificationEndPointConstants.REQUEST).
toString().replaceAll("\\\\r|\\\\n|\\r|\\n|\\[|]| ", StringUtils.EMPTY);
- byte[] decodedBytes = Base64.getDecoder().decode(eventPollingData);
- String decodedString = new String(decodedBytes, StandardCharsets.UTF_8);
- try {
- eventPollingRequest = (JSONObject) new JSONParser(JSONParser.MODE_PERMISSIVE).parse(decodedString);
-
- //check if the client id is present in the header
- String clientId = request.getHeader(EventNotificationConstants.X_WSO2_CLIENT_ID);
- if (!StringUtils.isBlank(clientId)) {
- eventPollingRequest.put(EventNotificationConstants.X_WSO2_CLIENT_ID, request.
- getHeader(EventNotificationConstants.X_WSO2_CLIENT_ID));
- } else {
+ if (!eventPollingData.isEmpty()) {
+ byte[] decodedBytes = Base64.getDecoder().decode(eventPollingData);
+ String decodedString = new String(decodedBytes, StandardCharsets.UTF_8);
+ try {
+ eventPollingRequest = (JSONObject) new JSONParser(JSONParser.MODE_PERMISSIVE).parse(decodedString);
+
+ //check if the client id is present in the header
+ String clientId = request.getHeader(EventNotificationConstants.X_WSO2_CLIENT_ID);
+ if (!StringUtils.isBlank(clientId)) {
+ eventPollingRequest.put(EventNotificationConstants.X_WSO2_CLIENT_ID, request.
+ getHeader(EventNotificationConstants.X_WSO2_CLIENT_ID));
+ } else {
+ return Response.status(Response.Status.BAD_REQUEST).entity(EventNotificationUtils.getErrorDTO(
+ EventNotificationEndPointConstants.MISSING_REQUEST_HEADER,
+ EventNotificationConstants.MISSING_HEADER_PARAM_CLIENT_ID)).build();
+ }
+
+ EventPollingResponse eventPollingResponse = eventPollingServiceHandler.
+ pollEvents(eventPollingRequest);
+
+ return EventNotificationUtils.mapEventPollingServiceResponse(eventPollingResponse);
+
+ } catch (ParseException e) {
+ log.error("Exception when parsing the request payload", e);
return Response.status(Response.Status.BAD_REQUEST).entity(EventNotificationUtils.getErrorDTO(
- EventNotificationEndPointConstants.MISSING_REQUEST_HEADER,
- EventNotificationConstants.MISSING_HEADER_PARAM_CLIENT_ID)).build();
+ EventNotificationEndPointConstants.INVALID_REQUEST_PAYLOAD,
+ EventNotificationEndPointConstants.REQUEST_PAYLOAD_ERROR)).build();
+ } catch (ClassCastException e) {
+ log.error(EventNotificationEndPointConstants.REQUEST_PAYLOAD_ERROR, e);
+ return Response.status(Response.Status.BAD_REQUEST).entity(EventNotificationUtils.getErrorDTO(
+ EventNotificationEndPointConstants.INVALID_REQUEST_PAYLOAD,
+ EventNotificationEndPointConstants.REQUEST_PAYLOAD_ERROR)).build();
}
-
- EventPollingResponse eventPollingResponse = eventPollingServiceHandler.
- pollEvents(eventPollingRequest);
-
- return EventNotificationUtils.mapEventPollingServiceResponse(eventPollingResponse);
-
- } catch (ParseException e) {
- log.error("Exception when parsing the request payload", e);
- return Response.status(Response.Status.BAD_REQUEST).entity(EventNotificationUtils.getErrorDTO(
- EventNotificationEndPointConstants.INVALID_REQUEST_PAYLOAD,
- EventNotificationEndPointConstants.REQUEST_PAYLOAD_ERROR)).build();
- } catch (ClassCastException e) {
- log.error(EventNotificationEndPointConstants.REQUEST_PAYLOAD_ERROR, e);
+ } else {
return Response.status(Response.Status.BAD_REQUEST).entity(EventNotificationUtils.getErrorDTO(
EventNotificationEndPointConstants.INVALID_REQUEST_PAYLOAD,
- EventNotificationEndPointConstants.REQUEST_PAYLOAD_ERROR)).build();
+ EventNotificationEndPointConstants.EMPTY_REQ_PAYLOAD)).build();
}
} else {
return Response.status(Response.Status.BAD_REQUEST).entity(EventNotificationUtils.getErrorDTO(
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/constants/EventNotificationEndPointConstants.java b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/constants/EventNotificationEndPointConstants.java
index ea9b3523..90530c99 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/constants/EventNotificationEndPointConstants.java
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/constants/EventNotificationEndPointConstants.java
@@ -29,6 +29,7 @@ public class EventNotificationEndPointConstants {
public static final String POLLING_ERROR_RESPONSE = "OB Event Notification Polling error";
public static final String EVENT_CREATION_ERROR_RESPONSE = "OB Event Notification Creation error";
public static final String REQUEST_PAYLOAD_ERROR = "Error in the request payload";
+ public static final String EMPTY_REQ_PAYLOAD = "Request payload cannot be empty";
public static final String INVALID_REQUEST = "invalid_request";
public static final String INVALID_REQUEST_PAYLOAD = "invalid_request_payload";
public static final String MISSING_REQUEST_PAYLOAD = "missing_request_payload";
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/util/EventNotificationUtils.java b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/util/EventNotificationUtils.java
index ab744948..9f7c038d 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/util/EventNotificationUtils.java
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/util/EventNotificationUtils.java
@@ -98,13 +98,16 @@ public static Response mapEventPollingServiceResponse(EventPollingResponse event
if (EventNotificationConstants.OK.equals(eventPollingResponse.getStatus())) {
return Response.status(Response.Status.OK).entity(eventPollingResponse.getResponseBody()).build();
+ } else if (EventNotificationConstants.NOT_FOUND.equals(eventPollingResponse.getStatus())) {
+ return Response.status(Response.Status.NOT_FOUND).entity(eventPollingResponse.getResponseBody()).build();
} else {
if (eventPollingResponse.getErrorResponse() instanceof String) {
- return Response.status(Response.Status.BAD_REQUEST).entity(EventNotificationUtils.getErrorDTO(
- EventNotificationEndPointConstants.INVALID_REQUEST,
- eventPollingResponse.getErrorResponse().toString())).build();
+ return Response.status(getErrorResponseStatus(eventPollingResponse.getStatus()))
+ .entity(EventNotificationUtils.getErrorDTO(EventNotificationEndPointConstants.INVALID_REQUEST,
+ eventPollingResponse.getErrorResponse().toString())).build();
} else {
- return Response.status(Response.Status.BAD_REQUEST).entity(eventPollingResponse.getErrorResponse())
+ return Response.status(getErrorResponseStatus(eventPollingResponse.getStatus()))
+ .entity(eventPollingResponse.getErrorResponse())
.build();
}
}
@@ -120,4 +123,20 @@ public static EventNotificationErrorDTO getErrorDTO(String error, String errorDe
eventNotificationErrorDTO.setErrorDescription(errorDescription);
return eventNotificationErrorDTO;
}
+
+ /**
+ * Get mapped Response.Status for the given status value.
+ * @param status status value
+ * @return Mapped Response.Status
+ */
+ private static Response.Status getErrorResponseStatus(String status) {
+
+ if (EventNotificationConstants.NOT_FOUND.equals(status)) {
+ return Response.Status.NOT_FOUND;
+ } else if (EventNotificationConstants.BAD_REQUEST.equals(status)) {
+ return Response.Status.BAD_REQUEST;
+ } else {
+ return Response.Status.INTERNAL_SERVER_ERROR;
+ }
+ }
}
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/util/EventSubscriptionUtils.java b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/util/EventSubscriptionUtils.java
index f5cd07f5..6c8ac0f1 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/util/EventSubscriptionUtils.java
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/util/EventSubscriptionUtils.java
@@ -29,7 +29,7 @@
import net.minidev.json.parser.JSONParser;
import net.minidev.json.parser.ParseException;
import org.apache.commons.io.IOUtils;
-import org.eclipse.jetty.http.HttpStatus;
+import org.springframework.http.HttpStatus;
import java.io.IOException;
@@ -76,22 +76,24 @@ public static JSONObject getJSONObjectPayload(HttpServletRequest request) throws
*/
public static Response mapEventSubscriptionServiceResponse(EventSubscriptionResponse eventSubscriptionResponse) {
int status = eventSubscriptionResponse.getStatus();
- if (eventSubscriptionResponse.getErrorResponse() == null) {
+ if (HttpStatus.NO_CONTENT.value() == status) {
+ return Response.status(status)
+ .build();
+ } else if (eventSubscriptionResponse.getErrorResponse() == null) {
if (eventSubscriptionResponse.getResponseBody() != null) {
return Response.status(status)
.entity(eventSubscriptionResponse.getResponseBody())
.build();
} else {
- return Response.status(HttpStatus.INTERNAL_SERVER_ERROR_500)
+ return Response.status(HttpStatus.INTERNAL_SERVER_ERROR.value())
.entity(EventNotificationServiceUtil.getErrorDTO(EventNotificationConstants.INVALID_REQUEST,
EventNotificationConstants.ERROR_HANDLING_EVENT_SUBSCRIPTION))
.build();
}
- } else {
+ } else {
return Response.status(status)
.entity(eventSubscriptionResponse.getErrorResponse())
.build();
}
-
}
}
From 5e3a1075659f1a9d1e97c8a27e02d2b068a00284 Mon Sep 17 00:00:00 2001
From: Ashirwada
Date: Fri, 3 Nov 2023 10:03:26 +0530
Subject: [PATCH 011/281] Fixing issues in Event Notification Implementation
---
.../constants/EventNotificationConstants.java | 2 +-
.../service/dao/AggregatedPollingDAO.java | 40 +++++-----
.../service/dao/AggregatedPollingDAOImpl.java | 76 ++++++++++---------
.../service/dao/EventPublisherDAO.java | 6 +-
.../service/dao/PostgreSqlPollingDAOImpl.java | 17 +++--
.../DefaultEventCreationServiceHandler.java | 11 ++-
.../DefaultEventPollingServiceHandler.java | 2 +-
.../handler/EventCreationServiceHandler.java | 2 +-
...NotificationPersistenceServiceHandler.java | 9 +++
.../handler/EventPollingServiceHandler.java | 6 +-
.../service/service/EventCreationService.java | 13 ++--
.../service/EventNotificationGenerator.java | 7 +-
.../service/service/EventPollingService.java | 8 +-
.../service/EventSubscriptionService.java | 6 ++
14 files changed, 119 insertions(+), 86 deletions(-)
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/constants/EventNotificationConstants.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/constants/EventNotificationConstants.java
index 12124024..835e2248 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/constants/EventNotificationConstants.java
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/constants/EventNotificationConstants.java
@@ -114,5 +114,5 @@ public class EventNotificationConstants {
public static final String EVENT_SUBSCRIPTION_NOT_FOUND = "Event subscription not found.";
public static final String EVENT_SUBSCRIPTIONS_NOT_FOUND = "Event subscriptions not found for the given client id.";
public static final String ERROR_HANDLING_EVENT_SUBSCRIPTION = "Error occurred while handling the event " +
- "subscription request";
+ "subscription request";
}
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/AggregatedPollingDAO.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/AggregatedPollingDAO.java
index 41c80dd2..8f98a2ad 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/AggregatedPollingDAO.java
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/AggregatedPollingDAO.java
@@ -35,18 +35,19 @@ public interface AggregatedPollingDAO {
* This method is to update the notification status by ID, allowed values are.
* OPEN,ACK and ERR
*
- * @param notificationId
- * @param notificationStatus
- * @return
+ * @param notificationId Notification ID to update
+ * @param notificationStatus Notification status to update
+ * @return Update is success or not
* @throws OBEventNotificationException
*/
Boolean updateNotificationStatusById(String notificationId, String notificationStatus)
throws OBEventNotificationException;
/**
- * This method is to store event notifications in the OB_NOTIFICATION table.
- * @param notificationError
- * @return
+ * This method is to store event notifications error details in the OB_NOTIFICATION table.
+ *
+ * @param notificationError Notification error details
+ * @return Stored event notifications error details
* @throws OBEventNotificationException
*/
Map storeErrorNotification(NotificationError notificationError)
@@ -54,10 +55,11 @@ Map storeErrorNotification(NotificationError notifica
/**
* This method is to retrieve given number of notifications in the OB_NOTIFICATION table by client and status.
- * @param clientId
- * @param status
- * @param max
- * @return
+ *
+ * @param clientId Client ID to retrieve notifications
+ * @param status Notification status to retrieve
+ * @param max Maximum number of notifications to retrieve
+ * @return List of notifications by client and status
* @throws OBEventNotificationException
*/
List getNotificationsByClientIdAndStatus(String clientId, String
@@ -65,28 +67,28 @@ List getNotificationsByClientIdAndStatus(String clientId, Strin
/**
* This method is to retrieve notifications by NotificationID.
- * @param notificationId
*
- * @return
+ * @param notificationId Notification ID to retrieve
+ * @return List of notifications by notification ID
* @throws OBEventNotificationException
*/
List getEventsByNotificationID(String notificationId) throws OBEventNotificationException;
/**
* This method is to retrieve notifications in the OB_NOTIFICATION table by status.
- * @param status
*
- * @return List
+ * @param status Notification status to retrieve
+ * @return List of notifications by status
* @throws OBEventNotificationException
*/
List getNotificationsByStatus(String status) throws OBEventNotificationException;
/**
* This method is to retrieve notificationsCount by ClientId and Status.
- * @param clientId
- * @param eventStatus
*
- * @return
+ * @param clientId Client ID to retrieve notifications
+ * @param eventStatus Notification status to retrieve
+ * @return List of notifications by status and client id
* @throws OBEventNotificationException
*/
int getNotificationCountByClientIdAndStatus(String clientId, String eventStatus)
@@ -94,9 +96,9 @@ int getNotificationCountByClientIdAndStatus(String clientId, String eventStatus)
/**
* This method is to retrieve the notification status.
- * @param notificationId
*
- * @return
+ * @param notificationId Notification ID to retrieve
+ * @return Notification status by notification ID
* @throws OBEventNotificationException
*/
boolean getNotificationStatus(String notificationId) throws OBEventNotificationException;
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/AggregatedPollingDAOImpl.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/AggregatedPollingDAOImpl.java
index 57708a1e..a14b74b7 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/AggregatedPollingDAOImpl.java
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/AggregatedPollingDAOImpl.java
@@ -61,7 +61,7 @@ public Boolean updateNotificationStatusById(String notificationId, String notifi
Connection connection = DatabaseUtil.getDBConnection();
if (log.isDebugEnabled()) {
log.debug(String.format("Database connection is established for updating notification with " +
- "ID : '%s' in the database. ", notificationId));
+ "ID : '%s' in the database. ", notificationId.replaceAll("[\r\n]", "")));
}
try {
connection.setAutoCommit(false);
@@ -78,32 +78,31 @@ public Boolean updateNotificationStatusById(String notificationId, String notifi
if (affectedRows != 0) {
connection.commit();
if (log.isDebugEnabled()) {
- log.debug("Updated notification with Notification ID : " + notificationId);
+ log.debug(String.format("Updated notification with Notification ID '%s'",
+ notificationId.replaceAll("[\r\n]", "")));
}
return true;
} else {
if (log.isDebugEnabled()) {
- log.debug("Failed updating notification with ID : " + notificationId);
+ log.debug(String.format("Failed updating notification with ID : '%s'",
+ notificationId.replaceAll("[\r\n]", "")));
}
return false;
}
} catch (SQLException e) {
connection.rollback(savepoint);
- log.error(String.format(EventNotificationConstants.DB_ERROR_UPDATING, notificationId), e);
+ log.error(String.format(EventNotificationConstants.DB_ERROR_UPDATING,
+ notificationId.replaceAll("[\r\n]", "")), e);
throw new OBEventNotificationException(String.format(EventNotificationConstants.DB_ERROR_UPDATING,
notificationId));
}
} catch (SQLException e) {
- if (log.isDebugEnabled()) {
- log.debug("SQL exception when updating notification status", e);
- }
+ log.debug("SQL exception when updating notification status", e);
throw new OBEventNotificationException("Database error while closing the connection to the" +
" the database.");
} finally {
- if (log.isDebugEnabled()) {
- log.debug(EventNotificationConstants.DATABASE_CONNECTION_CLOSE_LOG_MSG);
- }
+ log.debug(EventNotificationConstants.DATABASE_CONNECTION_CLOSE_LOG_MSG);
DatabaseUtil.closeConnection(connection);
}
}
@@ -119,8 +118,9 @@ public Map storeErrorNotification(NotificationError n
connection.setAutoCommit(false);
if (log.isDebugEnabled()) {
- log.debug("Database connection is established for storing error notification with ID : "
- + notificationError.getNotificationId());
+ log.debug(String.format("Database connection is established for storing error notification with ID" +
+ " : '%s' in the database. ",
+ notificationError.getNotificationId().replaceAll("[\r\n]", "")));
}
final String storeErrorNotificationQuery = sqlStatements.storeErrorNotificationQuery();
@@ -138,14 +138,14 @@ public Map storeErrorNotification(NotificationError n
if (affectedRows == 1) {
connection.commit();
if (log.isDebugEnabled()) {
- log.debug("Successfully stored error notification with ID : " +
- notificationError.getNotificationId());
+ log.debug(String.format("Successfully stored error notification with ID:'%s'.",
+ notificationError.getNotificationId().replaceAll("[\r\n]", "")));
}
response.put(notificationError.getNotificationId(), notificationError);
} else {
if (log.isDebugEnabled()) {
- log.debug(EventNotificationConstants.DB_FAILED_ERROR_NOTIFICATION_STORING
- + notificationError.getNotificationId());
+ log.debug(String.format("Failed store error notification with ID:'%s'.",
+ notificationError.getNotificationId().replaceAll("[\r\n]", "")));
}
throw new OBEventNotificationException(EventNotificationConstants.
DB_FAILED_ERROR_NOTIFICATION_STORING + notificationError.getNotificationId());
@@ -176,7 +176,8 @@ public List getNotificationsByClientIdAndStatus(String clientId
notificationList = new ArrayList<>();
if (log.isDebugEnabled()) {
- log.debug(String.format(EventNotificationConstants.DB_CONN_ESTABLISHED, clientId));
+ log.debug(String.format(EventNotificationConstants.DB_CONN_ESTABLISHED,
+ clientId.replaceAll("[\r\n]", "")));
}
final String sql = sqlStatements.getMaxNotificationsQuery();
@@ -215,12 +216,12 @@ public List getNotificationsByClientIdAndStatus(String clientId
if (log.isDebugEnabled()) {
log.debug(String.format(EventNotificationConstants.RETRIEVED_NOTIFICATION_CLIENT,
- clientId));
+ clientId.replaceAll("[\r\n]", "")));
}
} else {
if (log.isDebugEnabled()) {
log.debug(String.format(EventNotificationConstants.NO_NOTIFICATIONS_FOUND_CLIENT,
- clientId));
+ clientId.replaceAll("[\r\n]", "")));
}
}
}
@@ -268,7 +269,7 @@ public List getEventsByNotificationID(String notificationId)
(EventNotificationConstants.EVENT_TYPE));
event.setEventInformation(EventNotificationServiceUtil.
getEventJSONFromString(eventsResultSet.getString
- (EventNotificationConstants.EVENT_INFO)));
+ (EventNotificationConstants.EVENT_INFO)));
eventList.add(event);
}
eventsResultSet.close();
@@ -276,21 +277,23 @@ public List getEventsByNotificationID(String notificationId)
if (log.isDebugEnabled()) {
log.debug(String.format(EventNotificationConstants.RETRIEVED_EVENTS_NOTIFICATION,
- notificationId));
+ notificationId.replaceAll("[\r\n]", "")));
}
} else {
if (log.isDebugEnabled()) {
log.debug(String.format(EventNotificationConstants.NO_EVENTS_NOTIFICATION_ID,
- notificationId));
+ notificationId.replaceAll("[\r\n]", "")));
}
}
} catch (ParseException e) {
- log.error(String.format(EventNotificationConstants.PARSE_ERROR_NOTIFICATION_ID, notificationId), e);
+ log.error(String.format(EventNotificationConstants.PARSE_ERROR_NOTIFICATION_ID,
+ notificationId.replaceAll("[\r\n]", "")), e);
throw new OBEventNotificationException(String.format (
EventNotificationConstants.PARSE_ERROR_NOTIFICATION_ID, notificationId), e);
}
} catch (SQLException e) {
- log.error(String.format(EventNotificationConstants.DB_ERROR_EVENTS_RETRIEVE, notificationId), e);
+ log.error(String.format(EventNotificationConstants.DB_ERROR_EVENTS_RETRIEVE,
+ notificationId.replaceAll("[\r\n]", "")), e);
throw new OBEventNotificationException(String.format
(EventNotificationConstants.DB_ERROR_EVENTS_RETRIEVE, notificationId), e);
}
@@ -337,7 +340,8 @@ public List getNotificationsByStatus(String status) throws OBEv
notificationResultSet.close();
getNotificationsPreparedStatement.close();
if (log.isDebugEnabled()) {
- log.debug(EventNotificationConstants.RETRIEVED_NOTIFICATION_CLIENT);
+ log.debug(
+ EventNotificationConstants.RETRIEVED_NOTIFICATION_CLIENT);
}
} else {
if (log.isDebugEnabled()) {
@@ -378,7 +382,7 @@ public int getNotificationCountByClientIdAndStatus(String clientId, String event
if (log.isDebugEnabled()) {
log.debug(String.format("Retrieved notification count for client ID: '%s'. ",
- clientId));
+ clientId.replaceAll("[\r\n]", "")));
}
return count;
@@ -386,7 +390,7 @@ public int getNotificationCountByClientIdAndStatus(String clientId, String event
if (log.isDebugEnabled()) {
log.debug(String.format(
EventNotificationConstants.NO_NOTIFICATIONS_FOUND_CLIENT,
- clientId));
+ clientId.replaceAll("[\r\n]", "")));
}
return 0;
@@ -394,8 +398,7 @@ public int getNotificationCountByClientIdAndStatus(String clientId, String event
}
} catch (SQLException e) {
throw new OBEventNotificationException(String.format
- (EventNotificationConstants.DB_ERROR_NOTIFICATION_RETRIEVE,
- clientId), e);
+ (EventNotificationConstants.DB_ERROR_NOTIFICATION_RETRIEVE, clientId), e);
}
} finally {
log.debug(EventNotificationConstants.DATABASE_CONNECTION_CLOSE_LOG_MSG);
@@ -422,13 +425,14 @@ public boolean getNotificationStatus(String notificationId) throws OBEventNotifi
isOpenStatus = true;
}
- return isOpenStatus;
- } else {
- if (log.isDebugEnabled()) {
- log.debug("No notifications found for notification ID : " + notificationId);
- }
- }
- }
+ return isOpenStatus;
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("No notifications found for notification ID - '%s'",
+ notificationId.replaceAll("[\r\n]", "")));
+ }
+ }
+ }
} catch (SQLException e) {
throw new OBEventNotificationException(String.format
("Error occurred while retrieving status for the notifications ID : '%s'.",
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/EventPublisherDAO.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/EventPublisherDAO.java
index 7e59e93c..a410b770 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/EventPublisherDAO.java
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/EventPublisherDAO.java
@@ -32,9 +32,9 @@ public interface EventPublisherDAO {
/**
* This method is used to persist event notifications in the database.
- * @param connection
- * @param notificationDTO
- * @param eventsList
+ * @param connection Database connection
+ * @param notificationDTO Notification details DTO
+ * @param eventsList List of notification events
* @return NotificationID of the saved notification.
* @throws OBEventNotificationException
*/
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/PostgreSqlPollingDAOImpl.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/PostgreSqlPollingDAOImpl.java
index 7144e4e7..0421e4ec 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/PostgreSqlPollingDAOImpl.java
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/PostgreSqlPollingDAOImpl.java
@@ -59,7 +59,8 @@ public List getNotificationsByClientIdAndStatus(String clientId
notificationList = new ArrayList<>();
if (log.isDebugEnabled()) {
- log.debug(String.format(EventNotificationConstants.DB_CONN_ESTABLISHED, clientId));
+ log.debug(String.format(EventNotificationConstants.DB_CONN_ESTABLISHED,
+ clientId.replaceAll("[\r\n]", "")));
}
final String sql = sqlStatements.getMaxNotificationsQuery();
@@ -99,13 +100,13 @@ public List getNotificationsByClientIdAndStatus(String clientId
if (log.isDebugEnabled()) {
log.debug(String.format(EventNotificationConstants.RETRIEVED_NOTIFICATION_CLIENT,
- clientId));
+ clientId.replaceAll("[\r\n]", "")));
}
} else {
if (log.isDebugEnabled()) {
log.debug(String.format(EventNotificationConstants.NO_NOTIFICATIONS_FOUND_CLIENT,
- clientId));
+ clientId.replaceAll("[\r\n]", "")));
}
}
}
@@ -162,21 +163,23 @@ public List getEventsByNotificationID(String notificationId)
if (log.isDebugEnabled()) {
log.debug(String.format(EventNotificationConstants.RETRIEVED_EVENTS_NOTIFICATION,
- notificationId));
+ notificationId.replaceAll("[\r\n]", "")));
}
} else {
if (log.isDebugEnabled()) {
log.debug(String.format(EventNotificationConstants.NO_EVENTS_NOTIFICATION_ID,
- notificationId));
+ notificationId.replaceAll("[\r\n]", "")));
}
}
} catch (ParseException e) {
- log.error(String.format(EventNotificationConstants.PARSE_ERROR_NOTIFICATION_ID, notificationId), e);
+ log.error(String.format(EventNotificationConstants.PARSE_ERROR_NOTIFICATION_ID,
+ notificationId.replaceAll("[\r\n]", "")), e);
throw new OBEventNotificationException(String.format (
EventNotificationConstants.PARSE_ERROR_NOTIFICATION_ID, notificationId), e);
}
} catch (SQLException e) {
- log.error(String.format(EventNotificationConstants.DB_ERROR_EVENTS_RETRIEVE, notificationId), e);
+ log.error(String.format(EventNotificationConstants.DB_ERROR_EVENTS_RETRIEVE,
+ notificationId.replaceAll("[\r\n]", "")), e);
throw new OBEventNotificationException(String.format
(EventNotificationConstants.DB_ERROR_EVENTS_RETRIEVE, notificationId), e);
}
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/DefaultEventCreationServiceHandler.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/DefaultEventCreationServiceHandler.java
index 8a9f9c60..df5bd14a 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/DefaultEventCreationServiceHandler.java
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/DefaultEventCreationServiceHandler.java
@@ -43,6 +43,12 @@ public void setEventCreationService(EventCreationService eventCreationService) {
this.eventCreationService = eventCreationService;
}
+ /**
+ * This method is used to publish OB events in the accelerator database.
+ *
+ * @param notificationCreationDTO Notification details DTO
+ * @return EventCreationResponse Response after event creation
+ */
public EventCreationResponse publishOBEvent(NotificationCreationDTO notificationCreationDTO) {
//validate if the resourceID is existing
@@ -53,6 +59,7 @@ public EventCreationResponse publishOBEvent(NotificationCreationDTO notification
try {
consentResource = consentCoreService.getConsent(notificationCreationDTO.getResourceId(),
false);
+
if (log.isDebugEnabled()) {
log.debug("Consent resource available for resource ID " +
consentResource.getConsentID().replaceAll("[\r\n]", ""));
@@ -71,9 +78,9 @@ public EventCreationResponse publishOBEvent(NotificationCreationDTO notification
} catch (OBEventNotificationException e) {
log.error("Invalid client ID", e);
- eventCreationResponse.setErrorResponse(String.format(String.format("A client was not found" +
+ eventCreationResponse.setErrorResponse(String.format("A client was not found" +
" for the client id : '%s' in the database. ",
- notificationCreationDTO.getClientId())));
+ notificationCreationDTO.getClientId().replaceAll("[\r\n]", "")));
eventCreationResponse.setStatus(EventNotificationConstants.BAD_REQUEST);
return eventCreationResponse;
}
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/DefaultEventPollingServiceHandler.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/DefaultEventPollingServiceHandler.java
index c57dfd74..905a9802 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/DefaultEventPollingServiceHandler.java
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/DefaultEventPollingServiceHandler.java
@@ -66,7 +66,7 @@ public EventPollingResponse pollEvents(JSONObject eventPollingRequest) {
log.error("Invalid client ID", e);
eventPollingResponse.setStatus(EventNotificationConstants.BAD_REQUEST);
eventPollingResponse.setErrorResponse(EventNotificationServiceUtil.getErrorDTO(
- EventNotificationConstants.INVALID_REQUEST, String.format("A client was not found" +
+ EventNotificationConstants.INVALID_REQUEST, String.format("A client was not found" +
" for the client id : '%s' in the database.. ", eventPollingDTO.getClientId())));
return eventPollingResponse;
}
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/EventCreationServiceHandler.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/EventCreationServiceHandler.java
index 3f1c6877..671a64c6 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/EventCreationServiceHandler.java
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/EventCreationServiceHandler.java
@@ -30,7 +30,7 @@ public interface EventCreationServiceHandler {
/**
* This method is used to publish OB events in the accelerator database. The method is a generic
* method that is used to persist data into the OB_NOTIFICATION and OB_NOTIFICATION_EVENT tables.
- * @param notificationCreationDTO
+ * @param notificationCreationDTO Notification details DTO
* @return For successful request the API will return a JSON with the notificationID
*/
EventCreationResponse publishOBEvent(NotificationCreationDTO notificationCreationDTO);
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/EventNotificationPersistenceServiceHandler.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/EventNotificationPersistenceServiceHandler.java
index dfea1457..720d89a8 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/EventNotificationPersistenceServiceHandler.java
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/EventNotificationPersistenceServiceHandler.java
@@ -39,6 +39,15 @@ public static EventNotificationPersistenceServiceHandler getInstance() {
return instance;
}
+ /**
+ * This method is to persist authorization revoke event.
+ *
+ * @param clientId - client ID
+ * @param resourceId - resource ID
+ * @param notificationType - notification type
+ * @param notificationInfo - notification info
+ * @return EventCreationResponse
+ */
public EventCreationResponse persistRevokeEvent(String clientId,
String resourceId,
String notificationType, JSONObject notificationInfo) {
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/EventPollingServiceHandler.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/EventPollingServiceHandler.java
index 7a714db2..2c42d2dc 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/EventPollingServiceHandler.java
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/EventPollingServiceHandler.java
@@ -32,14 +32,14 @@ public interface EventPollingServiceHandler {
* This method follows the IETF Specification for SET delivery over HTTP.
* The method supports event acknowledgment in both positive and negative.
* Also, can be used to POLL for available OPEN notifications.
- * @param eventPollingRequest
+ * @param eventPollingRequest JSON request for event polling
* @return EventPollingResponse to the polling endpoint.
*/
EventPollingResponse pollEvents(JSONObject eventPollingRequest);
/**
- * This method is used to map the eventPollingRequest to EventPollingDTO.
- * @param eventPollingRequest
+ * This method is used to map the eventPollingRequest to EventPollingDTO
+ * @param eventPollingRequest JSON request for event polling
* @return eventPollingDTO with the request parameters.
*/
EventPollingDTO mapPollingRequest(JSONObject eventPollingRequest);
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/service/EventCreationService.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/service/EventCreationService.java
index 466e0f33..025984b6 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/service/EventCreationService.java
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/service/EventCreationService.java
@@ -48,10 +48,9 @@ public class EventCreationService {
/**
* The publishOBEventNotification methods will call the dao layer to persist the event
- * notifications
- * event polling request.
- * @param notificationCreationDTO
- *
+ * notifications for event polling request.
+ * @param notificationCreationDTO Notification Creation DTO
+ * @return Event Response
* @throws OBEventNotificationException
*/
public String publishOBEventNotification(NotificationCreationDTO notificationCreationDTO)
@@ -84,7 +83,8 @@ public String publishOBEventNotification(NotificationCreationDTO notificationCre
/**
* The getEvents method is used to get the NotificationEvents Array list from payload.
*
- * @param notificationEvents
+ * @param notificationEvents Notification Events to convert
+ * @return Event notification List
*/
@Generated(message = "Private methods invoked when calling referred method")
private ArrayList getEvents(Map notificationEvents) {
@@ -104,7 +104,8 @@ private ArrayList getEvents(Map notificat
/**
* The getNotification method is used to get the NotificationDAO from payload.
*
- * @param notificationCreationDTO
+ * @param notificationCreationDTO Notification Creation DTO
+ * @return Notification Details
*/
@Generated(message = "Private methods invoked when calling referred method")
private NotificationDTO getNotification(NotificationCreationDTO notificationCreationDTO) {
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/service/EventNotificationGenerator.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/service/EventNotificationGenerator.java
index fc24e51e..4eb6dc9c 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/service/EventNotificationGenerator.java
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/service/EventNotificationGenerator.java
@@ -35,9 +35,10 @@ public interface EventNotificationGenerator {
/**
* This method is to generate event notification body. To generate custom values
* for the body this method should be extended.
- * @param notificationDTO
- * @param notificationEventList
- * @return
+ * @param notificationDTO Notification details DTO
+ * @param notificationEventList List of notification events
+ *
+ * @return Event Notification Body
* @throws OBEventNotificationException
*/
Notification generateEventNotificationBody(NotificationDTO notificationDTO, List
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/service/EventPollingService.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/service/EventPollingService.java
index a823288a..aa7495d0 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/service/EventPollingService.java
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/service/EventPollingService.java
@@ -50,8 +50,8 @@ public class EventPollingService {
/**
* The pollEvents methods will return the Aggregated Polling Response for
* event polling request.
- * @param eventPollingDTO
- *
+ * @param eventPollingDTO Event polling request DTO
+ * @return AggregatedPollingResponse Aggregated Polling Response
* @throws OBEventNotificationException
*/
public AggregatedPollingResponse pollEvents(EventPollingDTO eventPollingDTO)
@@ -107,13 +107,13 @@ public AggregatedPollingResponse pollEvents(EventPollingDTO eventPollingDTO)
if (notificationList.isEmpty()) {
if (log.isDebugEnabled()) {
log.debug(String.format("No OB Event Notifications available for for the client " +
- "with ID : '%s'.", eventPollingDTO.getClientId()));
+ "with ID : '%s'.", eventPollingDTO.getClientId().replaceAll("[\r\n]", "")));
}
aggregatedPollingResponse.setStatus(EventNotificationConstants.NOT_FOUND);
} else {
if (log.isDebugEnabled()) {
log.debug(String.format("OB Event Notifications available for the client " +
- "with ID : '%s'.", eventPollingDTO.getClientId()));
+ "with ID : '%s'.", eventPollingDTO.getClientId().replaceAll("[\r\n]", "")));
}
aggregatedPollingResponse.setStatus(EventNotificationConstants.OK);
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/service/EventSubscriptionService.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/service/EventSubscriptionService.java
index 20e9d55d..a0b84125 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/service/EventSubscriptionService.java
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/service/EventSubscriptionService.java
@@ -43,6 +43,7 @@ public class EventSubscriptionService {
* This method will call the dao layer to persist the event subscription.
*
* @param eventSubscription event subscription object that needs to be persisted
+ * @return event subscription object that is persisted
* @throws OBEventNotificationException
*/
public EventSubscription createEventSubscription(EventSubscription eventSubscription)
@@ -78,6 +79,7 @@ public EventSubscription createEventSubscription(EventSubscription eventSubscrip
* This method will call the dao layer to retrieve a single event subscription.
*
* @param subscriptionId subscription id of the event subscription
+ * @return event subscription object that is retrieved
* @throws OBEventNotificationException
*/
public EventSubscription getEventSubscriptionBySubscriptionId(String subscriptionId)
@@ -101,6 +103,7 @@ public EventSubscription getEventSubscriptionBySubscriptionId(String subscriptio
* This method will call the dao layer to retrieve all event subscriptions of a client.
*
* @param clientId client id of the event subscription
+ * @return list of event subscriptions that are retrieved
* @throws OBEventNotificationException
*/
public List getEventSubscriptionsByClientId(String clientId)
@@ -122,6 +125,7 @@ public List getEventSubscriptionsByClientId(String clientId)
* This method will call the dao layer to retrieve all event subscriptions by event type.
*
* @param eventType event type that needs to be subscribed by the retrieving event subscriptions.
+ * @return list of event subscriptions that are retrieved
* @throws OBEventNotificationException
*/
public List getEventSubscriptionsByClientIdAndEventType(String eventType)
@@ -144,6 +148,7 @@ public List getEventSubscriptionsByClientIdAndEventType(Strin
* This method will call the dao layer to update an event subscription.
*
* @param eventSubscription event subscription object that needs to be updated
+ * @return true if the event subscription is updated successfully
* @throws OBEventNotificationException
*/
public Boolean updateEventSubscription(EventSubscription eventSubscription)
@@ -206,6 +211,7 @@ public Boolean updateEventSubscription(EventSubscription eventSubscription)
* This method will call the dao layer to delete an event subscription.
*
* @param subscriptionId subscription id of the event subscription
+ * @return true if the event subscription is deleted successfully
* @throws OBEventNotificationException
*/
public Boolean deleteEventSubscription(String subscriptionId) throws OBEventNotificationException {
From 28d685192b936670fb2f555a7b389c1c4ea90d16 Mon Sep 17 00:00:00 2001
From: hasithakn
Date: Wed, 8 Nov 2023 22:33:05 +0530
Subject: [PATCH 012/281] Improve DCR signature validation logic (sandbox vs
prod)
---
.../repository/conf/open-banking.xml.j2 | 14 ++++
.../resources/wso2am-4.0.0-deployment.toml | 4 +
.../resources/wso2am-4.1.0-deployment.toml | 4 +
.../resources/wso2am-4.2.0-deployment.toml | 4 +
.../repository/conf/open-banking.xml.j2 | 12 +++
.../resources/wso2is-5.11.0-deployment.toml | 4 +
.../resources/wso2is-6.0.0-deployment.toml | 4 +
.../resources/wso2is-6.1.0-deployment.toml | 4 +
.../config/OpenBankingConfigParser.java | 22 +++++
.../common/constant/OpenBankingConstants.java | 4 +
.../common/util/OpenBankingUtils.java | 28 +++++++
.../test/util/OpenBankingUtilsTest.java | 82 +++++++++++++++++++
.../gateway/executor/dcr/DCRExecutor.java | 25 +-----
.../gateway/executor/dcr/DCRExecutorTest.java | 14 +++-
.../dcr/validation/SignatureValidator.java | 29 ++++---
...ignatureAlgorithmEnforcementValidator.java | 3 +-
16 files changed, 219 insertions(+), 38 deletions(-)
diff --git a/open-banking-accelerator/accelerators/ob-apim/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2 b/open-banking-accelerator/accelerators/ob-apim/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
index 6e261320..e26f6d73 100644
--- a/open-banking-accelerator/accelerators/ob-apim/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
+++ b/open-banking-accelerator/accelerators/ob-apim/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
@@ -301,6 +301,20 @@
{% else %}
true
{% endif %}
+
+
+ {% if open_banking.dcr.registration.software_environment_identification.ssa_property_name is defined %}
+ {{open_banking.dcr.registration.software_environment_identification.ssa_property_name}}
+ {% else %}
+ software_environment
+ {% endif %}
+ {% if open_banking.dcr.registration.software_environment_identification.ssa_property_value_for_sandbox is defined %}
+ {{open_banking.dcr.registration.software_environment_identification.ssa_property_value_for_sandbox}}
+ {% else %}
+ sandbox
+ {% endif %}
+
+ {{open_banking.keyManager.name}}
{% if open_banking.publisher.hostname is defined %}
diff --git a/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.0.0-deployment.toml b/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.0.0-deployment.toml
index dc1e2509..42683bfc 100644
--- a/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.0.0-deployment.toml
+++ b/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.0.0-deployment.toml
@@ -431,6 +431,10 @@ roles = "AISP,PISP"
api_name = "AccountandTransactionAPI"
roles = "AISP"
+[open_banking.dcr.registration.software_environment_identification]
+ssa_property_name = "software_environment"
+ssa_property_value_for_sandbox = "sandbox"
+
#============executors=========================
[[open_banking.gateway.openbanking_gateway_executors.type]]
name = "Default"
diff --git a/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.1.0-deployment.toml b/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.1.0-deployment.toml
index 5418fc2e..80e70a64 100644
--- a/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.1.0-deployment.toml
+++ b/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.1.0-deployment.toml
@@ -431,6 +431,10 @@ roles = "AISP,PISP"
api_name = "AccountandTransactionAPI"
roles = "AISP"
+[open_banking.dcr.registration.software_environment_identification]
+ssa_property_name = "software_environment"
+ssa_property_value_for_sandbox = "sandbox"
+
#============executors=========================
[[open_banking.gateway.openbanking_gateway_executors.type]]
name = "Default"
diff --git a/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.2.0-deployment.toml b/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.2.0-deployment.toml
index 6e7a23c2..5fbe2415 100644
--- a/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.2.0-deployment.toml
+++ b/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.2.0-deployment.toml
@@ -435,6 +435,10 @@ roles = "AISP,PISP"
api_name = "AccountandTransactionAPI"
roles = "AISP"
+[open_banking.dcr.registration.software_environment_identification]
+ssa_property_name = "software_environment"
+ssa_property_value_for_sandbox = "sandbox"
+
#============executors=========================
[[open_banking.gateway.openbanking_gateway_executors.type]]
name = "Default"
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2 b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
index 9b0a5cfa..7bbcdaac 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
@@ -455,6 +455,18 @@
https://localhost:8243/open-banking/0.1/register/
{% endif %}
+
+ {% if open_banking.dcr.registration.software_environment_identification.ssa_property_name is defined %}
+ {{open_banking.dcr.registration.software_environment_identification.ssa_property_name}}
+ {% else %}
+ software_environment
+ {% endif %}
+ {% if open_banking.dcr.registration.software_environment_identification.ssa_property_value_for_sandbox is defined %}
+ {{open_banking.dcr.registration.software_environment_identification.ssa_property_value_for_sandbox}}
+ {% else %}
+ sandbox
+ {% endif %}
+
{% if open_banking.dcr.registration.grant_types.required is defined %}
{{open_banking.dcr.registration.grant_types.required}}
diff --git a/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-5.11.0-deployment.toml b/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-5.11.0-deployment.toml
index 9b7bdf22..3c70545e 100644
--- a/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-5.11.0-deployment.toml
+++ b/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-5.11.0-deployment.toml
@@ -406,6 +406,10 @@ read_timeout = 3000
[[open_banking.dcr.regulatory_issuers.iss]]
name = "OpenBanking Ltd"
+[open_banking.dcr.registration.software_environment_identification]
+ssa_property_name = "software_environment"
+ssa_property_value_for_sandbox = "sandbox"
+
#Signature algorithm types that are allowed
#[[open_banking.signature_validation.allowed_algorithms]]
#name = "PS256"
diff --git a/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-6.0.0-deployment.toml b/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-6.0.0-deployment.toml
index 0798f3d3..133e0552 100644
--- a/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-6.0.0-deployment.toml
+++ b/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-6.0.0-deployment.toml
@@ -406,6 +406,10 @@ read_timeout = 3000
[[open_banking.dcr.regulatory_issuers.iss]]
name = "OpenBanking Ltd"
+[open_banking.dcr.registration.software_environment_identification]
+ssa_property_name = "software_environment"
+ssa_property_value_for_sandbox = "sandbox"
+
#Signature algorithm types that are allowed
#[[open_banking.signature_validation.allowed_algorithms]]
#name = "PS256"
diff --git a/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-6.1.0-deployment.toml b/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-6.1.0-deployment.toml
index 0b6e3cbb..a14e9525 100644
--- a/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-6.1.0-deployment.toml
+++ b/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-6.1.0-deployment.toml
@@ -406,6 +406,10 @@ read_timeout = 3000
[[open_banking.dcr.regulatory_issuers.iss]]
name = "OpenBanking Ltd"
+[open_banking.dcr.registration.software_environment_identification]
+ssa_property_name = "software_environment"
+ssa_property_value_for_sandbox = "sandbox"
+
#Signature algorithm types that are allowed
#[[open_banking.signature_validation.allowed_algorithms]]
#name = "PS256"
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/config/OpenBankingConfigParser.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/config/OpenBankingConfigParser.java
index e43625cd..776e8263 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/config/OpenBankingConfigParser.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/config/OpenBankingConfigParser.java
@@ -1397,6 +1397,28 @@ public String getRealtimeEventNotificationRequestGenerator() {
: (String) getConfigElementFromKey(OpenBankingConstants.REALTIME_EVENT_NOTIFICATION_REQUEST_GENERATOR);
}
+ /**
+ * Method to get software environment identification SSA property name.
+ *
+ * @return String software environment identification SSA property name.
+ */
+ public String getSoftwareEnvIdentificationSSAPropertyName() {
+ return getConfigElementFromKey(OpenBankingConstants.DCR_SOFTWARE_ENV_IDENTIFICATION_PROPERTY_NAME) == null ?
+ OpenBankingConstants.SOFTWARE_ENVIRONMENT : (String) getConfigElementFromKey(
+ OpenBankingConstants.DCR_SOFTWARE_ENV_IDENTIFICATION_PROPERTY_NAME);
+ }
+
+ /**
+ * Method to get software environment identification value for sandbox in SSA.
+ *
+ * @return String software environment identification value for sandbox.
+ */
+ public String getSoftwareEnvIdentificationSSAPropertyValueForSandbox() {
+ return getConfigElementFromKey(OpenBankingConstants.DCR_SOFTWARE_ENV_IDENTIFICATION_VALUE_FOR_SANDBOX) == null ?
+ "sandbox" : (String) getConfigElementFromKey(
+ OpenBankingConstants.DCR_SOFTWARE_ENV_IDENTIFICATION_VALUE_FOR_SANDBOX);
+ }
+
/**
* Get config related for checking whether PSU is a federated user or not.
*
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/constant/OpenBankingConstants.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/constant/OpenBankingConstants.java
index 52409911..e29c00b9 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/constant/OpenBankingConstants.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/constant/OpenBankingConstants.java
@@ -62,6 +62,10 @@ public class OpenBankingConstants {
public static final String DCR_JWKS_NAME = "DCR.JWKSEndpointName";
public static final String DCR_APPLICATION_NAME_KEY = "DCR.ApplicationName";
public static final String OB_KM_NAME = "KeyManagerName";
+ public static final String DCR_SOFTWARE_ENV_IDENTIFICATION_PROPERTY_NAME =
+ "DCR.RegistrationRequestParams.SoftwareEnvironmentIdentification.PropertyName";
+ public static final String DCR_SOFTWARE_ENV_IDENTIFICATION_VALUE_FOR_SANDBOX =
+ "DCR.RegistrationRequestParams.SoftwareEnvironmentIdentification.PropertyValueForSandbox";
public static final String APIM_APPCREATION = "DCR.APIMRESTEndPoints.AppCreation";
public static final String APIM_KEYGENERATION = "DCR.APIMRESTEndPoints.KeyGeneration";
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/OpenBankingUtils.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/OpenBankingUtils.java
index 3f19f805..a2ddbaf9 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/OpenBankingUtils.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/OpenBankingUtils.java
@@ -19,11 +19,14 @@
import com.wso2.openbanking.accelerator.common.config.OpenBankingConfigParser;
import com.wso2.openbanking.accelerator.common.exception.OpenBankingRuntimeException;
+import com.wso2.openbanking.accelerator.common.identity.IdentityConstants;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import net.minidev.json.JSONObject;
import java.lang.reflect.InvocationTargetException;
+import java.text.ParseException;
/**
* Open Banking common utility class.
@@ -53,6 +56,31 @@ public static Object getClassInstanceFromFQN(String classpath) {
}
}
+ /**
+ * Extract software_environment (SANDBOX or PRODUCTION) from SSA
+ *
+ * @param softwareStatement software statement (jwt) extracted from request payload
+ * @return software_environment
+ * @throws ParseException
+ */
+ public static String getSoftwareEnvironmentFromSSA(String softwareStatement) throws ParseException {
+
+ String sandboxEnvIdentificationPropertyName = OpenBankingConfigParser.getInstance()
+ .getSoftwareEnvIdentificationSSAPropertyName();
+ String sandboxEnvIdentificationValue = OpenBankingConfigParser.getInstance()
+ .getSoftwareEnvIdentificationSSAPropertyValueForSandbox();
+ String softwareEnvironment = IdentityConstants.PRODUCTION;
+ // decode software statement and get softwareEnvironment
+ JSONObject softwareStatementBody = JWTUtils.decodeRequestJWT(softwareStatement, "body");
+ Object softwareEnvironmentValue = softwareStatementBody.get(sandboxEnvIdentificationPropertyName);
+ if (softwareEnvironmentValue != null &&
+ softwareEnvironmentValue.toString().equalsIgnoreCase(sandboxEnvIdentificationValue)) {
+ softwareEnvironment = IdentityConstants.SANDBOX;
+ }
+ return softwareEnvironment;
+ }
+
+
/**
* Method to obtain boolean value for check if the Dispute Resolution Data is publishable.
*
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/OpenBankingUtilsTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/OpenBankingUtilsTest.java
index 8e5b76aa..5a408663 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/OpenBankingUtilsTest.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/OpenBankingUtilsTest.java
@@ -19,6 +19,7 @@
package com.wso2.openbanking.accelerator.common.test.util;
import com.wso2.openbanking.accelerator.common.config.OpenBankingConfigParser;
+import com.wso2.openbanking.accelerator.common.identity.IdentityConstants;
import com.wso2.openbanking.accelerator.common.util.OpenBankingUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -31,6 +32,8 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.text.ParseException;
+
import static org.mockito.Mockito.when;
@@ -55,6 +58,85 @@ public void before() {
}
+ @Test(priority = 1)
+ public void getSoftwareEnvironmentFromSSA() throws ParseException {
+ String sandboxSsa = "eyJ0eXAiOiJKV1QiLCJraWQiOiJoM1pDRjBWcnpnWGduSENxYkhiS1h6emZqVGciLCJhbGciOiJQUzI1NiJ9." +
+ "eyJpYXQiOjE2OTg2ODQ4MjUsIm5iZiI6MTY5ODY4NDgyMSwiZXhwIjoxNjk4Njg4NDI2LCJqdGkiOiIyNDdlNjdmNjBmODA0YT" +
+ "k5MTY5ODY4NDgyNSIsImlzcyI6Ik9wZW5CYW5raW5nIEx0ZCIsInNvZnR3YXJlX2Vudmlyb25tZW50Ijoic2FuZGJveCIsInNv" +
+ "ZnR3YXJlX21vZGUiOiJUZXN0Iiwic29mdHdhcmVfaWQiOiIxMlp6RkZCeFNMR0VqUFpvZ1JBYnZGZHMxMTY5ODY4NDgyNSIsIn" +
+ "NvZnR3YXJlX2NsaWVudF9pZCI6IjEwWnpGRkJ4U0xHRWpQWm9nUkFidkZkczEiLCJzb2Z0d2FyZV9jbGllbnRfbmFtZSI6IldT" +
+ "TzIgT3BlbiBCYW5raW5nIFRQUCAoU2FuZGJveCkiLCJzb2Z0d2FyZV9jbGllbnRfZGVzY3JpcHRpb24iOiJXU08yIE9wZW4gQm" +
+ "Fua2luZyBUUFAgZm9yIHRlc3RpbmciLCJzb2Z0d2FyZV92ZXJzaW9uIjoxLjUsInNvZnR3YXJlX2NsaWVudF91cmkiOiJodHRw" +
+ "czovL3d3dy5nb29nbGUuY29tIiwic29mdHdhcmVfcmVkaXJlY3RfdXJpcyI6WyJodHRwczovL3d3dy5nb29nbGUuY29tL3JlZG" +
+ "lyZWN0cy9yZWRpcmVjdDEiXSwic29mdHdhcmVfcm9sZXMiOlsiUElTUCIsIkFJU1AiLCJDQlBJSSJdLCJvcmdhbmlzYXRpb25f" +
+ "Y29tcGV0ZW50X2F1dGhvcml0eV9jbGFpbXMiOnsiYXV0aG9yaXR5X2lkIjoiT0JHQlIiLCJyZWdpc3RyYXRpb25faWQiOiJVbm" +
+ "tub3duMDAxNTgwMDAwMUhRUXJaQUFYIiwic3RhdHVzIjoiQWN0aXZlIiwiYXV0aG9yaXNhdGlvbnMiOlt7Im1lbWJlcl9zdGF0" +
+ "ZSI6IkdCIiwicm9sZXMiOlsiUElTUCIsIkFJU1AiLCJDQlBJSSJdfSx7Im1lbWJlcl9zdGF0ZSI6IklFIiwicm9sZXMiOlsiUE" +
+ "lTUCIsIkNCUElJIiwiQUlTUCJdfSx7Im1lbWJlcl9zdGF0ZSI6Ik5MIiwicm9sZXMiOlsiUElTUCIsIkFJU1AiLCJDQlBJSSJd" +
+ "fV19LCJzb2Z0d2FyZV9sb2dvX3VyaSI6Imh0dHBzOi8vd3d3Lmdvb2dsZS5jb20iLCJvcmdfc3RhdHVzIjoiQWN0aXZlIiwib3" +
+ "JnX2lkIjoiMDAxNTgwMDAwMUhRUXJaQUFYIiwib3JnX25hbWUiOiJXU08yIChVSykgTElNSVRFRCIsIm9yZ19jb250YWN0cyI6" +
+ "W3sibmFtZSI6IlRlY2huaWNhbCIsImVtYWlsIjoic2FjaGluaXNAd3NvMi5jb20iLCJwaG9uZSI6Iis5NDc3NDI3NDM3NCIsIn" +
+ "R5cGUiOiJUZWNobmljYWwifSx7Im5hbWUiOiJCdXNpbmVzcyIsImVtYWlsIjoic2FjaGluaXNAd3NvMi5jb20iLCJwaG9uZSI6" +
+ "Iis5NDc3NDI3NDM3NCIsInR5cGUiOiJCdXNpbmVzcyJ9XSwib3JnX2p3a3NfZW5kcG9pbnQiOiJodHRwczovL2tleXN0b3JlLm" +
+ "9wZW5iYW5raW5ndGVzdC5vcmcudWsvMDAxNTgwMDAwMUhRUXJaQUFYLzAwMTU4MDAwMDFIUVFyWkFBWC5qd2tzIiwib3JnX2p3" +
+ "a3NfcmV2b2tlZF9lbmRwb2ludCI6Imh0dHBzOi8va2V5c3RvcmUub3BlbmJhbmtpbmd0ZXN0Lm9yZy51ay8wMDE1ODAwMDAxSF" +
+ "FRclpBQVgvcmV2b2tlZC8wMDE1ODAwMDAxSFFRclpBQVguandrcyIsInNvZnR3YXJlX2p3a3NfZW5kcG9pbnQiOiJodHRwczov" +
+ "L2tleXN0b3JlLm9wZW5iYW5raW5ndGVzdC5vcmcudWsvMDAxNTgwMDAwMUhRUXJaQUFYLzAwMTU4MDAwMDFIUVFyWkFBWC5qd2" +
+ "tzIiwic29mdHdhcmVfandrc19yZXZva2VkX2VuZHBvaW50IjoiaHR0cHM6Ly9rZXlzdG9yZS5vcGVuYmFua2luZ3Rlc3Qub3Jn" +
+ "LnVrLzAwMTU4MDAwMDFIUVFyWkFBWC9yZXZva2VkLzlaekZGQnhTTEdFalBab2dSQWJ2RmQuandrcyIsInNvZnR3YXJlX3BvbG" +
+ "ljeV91cmkiOiJodHRwczovL3d3dy5nb29nbGUuY29tIiwic29mdHdhcmVfdG9zX3VyaSI6Imh0dHBzOi8vd3d3Lmdvb2dsZS5j" +
+ "b20iLCJzb2Z0d2FyZV9vbl9iZWhhbGZfb2Zfb3JnIjpudWxsfQ.SUZaSo0sEfBU2ffN73IqNG8KAoYEO8vUIrZHBOxA-gF5dKN" +
+ "IZR6pQ9cnuc3NzhmfHr9TAhiC_KVV9ULiwg0Kh0V79z57Ykjz6NuZ8m0tZPQbjOMQBrRXdnLkqqot_pO_2vwLCRFDfhWM2wqR4" +
+ "lTXkM0KsdNSWgG3vl25JTkwqo1tTsYlZUcQFltlLQ-lCXT2nWnu_dPZWUqzVb9g4s2DcQ78xkJwqHJKgGLsloXzAMDx36MZQ01" +
+ "fHP2eIFu82D0PgsxqvHbNeyXVlg5XsX5TLRwrRy8W4wP_SLMoP7jDic0yEufBRULROX2ckpoZuk31a_QyaJFKtIiPj9zlltM9Zg";
+ PowerMockito.when(OpenBankingConfigParser.getInstance()
+ .getSoftwareEnvIdentificationSSAPropertyValueForSandbox()).thenReturn("sandbox");
+ PowerMockito.when(OpenBankingConfigParser.getInstance()
+ .getSoftwareEnvIdentificationSSAPropertyName()).thenReturn("software_environment");
+ String softwareEnvironmentFromSSA = OpenBankingUtils.getSoftwareEnvironmentFromSSA(sandboxSsa);
+ Assert.assertEquals(softwareEnvironmentFromSSA, IdentityConstants.SANDBOX);
+ }
+
+ @Test()
+ public void getSoftwareEnvironmentFromSSAForProd() throws ParseException {
+ String prodSsa = "eyJ0eXAiOiJKV1QiLCJraWQiOiJoM1pDRjBWcnpnWGduSENxYkhiS1h6emZqVGciLCJhbGciOiJQUzI1NiJ9." +
+ "eyJpYXQiOjE2OTg2ODQ4MjUsIm5iZiI6MTY5ODY4NDgyMSwiZXhwIjoxNjk4Njg4NDI2LCJqdGkiOiIyNDdlNjdmNjBmODA0YT" +
+ "k5MTY5ODY4NDgyNSIsImlzcyI6Ik9wZW5CYW5raW5nIEx0ZCIsInNvZnR3YXJlX2Vudmlyb25tZW50IjoicHJvZCIsInNvZnR3" +
+ "YXJlX21vZGUiOiJUZXN0Iiwic29mdHdhcmVfaWQiOiIxMlp6RkZCeFNMR0VqUFpvZ1JBYnZGZHMxMTY5ODY4NDgyNSIsInNvZn" +
+ "R3YXJlX2NsaWVudF9pZCI6IjEwWnpGRkJ4U0xHRWpQWm9nUkFidkZkczEiLCJzb2Z0d2FyZV9jbGllbnRfbmFtZSI6IldTTzIg" +
+ "T3BlbiBCYW5raW5nIFRQUCAoU2FuZGJveCkiLCJzb2Z0d2FyZV9jbGllbnRfZGVzY3JpcHRpb24iOiJXU08yIE9wZW4gQmFua2" +
+ "luZyBUUFAgZm9yIHRlc3RpbmciLCJzb2Z0d2FyZV92ZXJzaW9uIjoxLjUsInNvZnR3YXJlX2NsaWVudF91cmkiOiJodHRwczov" +
+ "L3d3dy5nb29nbGUuY29tIiwic29mdHdhcmVfcmVkaXJlY3RfdXJpcyI6WyJodHRwczovL3d3dy5nb29nbGUuY29tL3JlZGlyZW" +
+ "N0cy9yZWRpcmVjdDEiXSwic29mdHdhcmVfcm9sZXMiOlsiUElTUCIsIkFJU1AiLCJDQlBJSSJdLCJvcmdhbmlzYXRpb25fY29t" +
+ "cGV0ZW50X2F1dGhvcml0eV9jbGFpbXMiOnsiYXV0aG9yaXR5X2lkIjoiT0JHQlIiLCJyZWdpc3RyYXRpb25faWQiOiJVbmtub3" +
+ "duMDAxNTgwMDAwMUhRUXJaQUFYIiwic3RhdHVzIjoiQWN0aXZlIiwiYXV0aG9yaXNhdGlvbnMiOlt7Im1lbWJlcl9zdGF0ZSI6" +
+ "IkdCIiwicm9sZXMiOlsiUElTUCIsIkFJU1AiLCJDQlBJSSJdfSx7Im1lbWJlcl9zdGF0ZSI6IklFIiwicm9sZXMiOlsiUElTUC" +
+ "IsIkNCUElJIiwiQUlTUCJdfSx7Im1lbWJlcl9zdGF0ZSI6Ik5MIiwicm9sZXMiOlsiUElTUCIsIkFJU1AiLCJDQlBJSSJdfV19" +
+ "LCJzb2Z0d2FyZV9sb2dvX3VyaSI6Imh0dHBzOi8vd3d3Lmdvb2dsZS5jb20iLCJvcmdfc3RhdHVzIjoiQWN0aXZlIiwib3JnX2" +
+ "lkIjoiMDAxNTgwMDAwMUhRUXJaQUFYIiwib3JnX25hbWUiOiJXU08yIChVSykgTElNSVRFRCIsIm9yZ19jb250YWN0cyI6W3si" +
+ "bmFtZSI6IlRlY2huaWNhbCIsImVtYWlsIjoic2FjaGluaXNAd3NvMi5jb20iLCJwaG9uZSI6Iis5NDc3NDI3NDM3NCIsInR5cG" +
+ "UiOiJUZWNobmljYWwifSx7Im5hbWUiOiJCdXNpbmVzcyIsImVtYWlsIjoic2FjaGluaXNAd3NvMi5jb20iLCJwaG9uZSI6Iis5" +
+ "NDc3NDI3NDM3NCIsInR5cGUiOiJCdXNpbmVzcyJ9XSwib3JnX2p3a3NfZW5kcG9pbnQiOiJodHRwczovL2tleXN0b3JlLm9wZW" +
+ "5iYW5raW5ndGVzdC5vcmcudWsvMDAxNTgwMDAwMUhRUXJaQUFYLzAwMTU4MDAwMDFIUVFyWkFBWC5qd2tzIiwib3JnX2p3a3Nf" +
+ "cmV2b2tlZF9lbmRwb2ludCI6Imh0dHBzOi8va2V5c3RvcmUub3BlbmJhbmtpbmd0ZXN0Lm9yZy51ay8wMDE1ODAwMDAxSFFRcl" +
+ "pBQVgvcmV2b2tlZC8wMDE1ODAwMDAxSFFRclpBQVguandrcyIsInNvZnR3YXJlX2p3a3NfZW5kcG9pbnQiOiJodHRwczovL2tl" +
+ "eXN0b3JlLm9wZW5iYW5raW5ndGVzdC5vcmcudWsvMDAxNTgwMDAwMUhRUXJaQUFYLzAwMTU4MDAwMDFIUVFyWkFBWC5qd2tzIi" +
+ "wic29mdHdhcmVfandrc19yZXZva2VkX2VuZHBvaW50IjoiaHR0cHM6Ly9rZXlzdG9yZS5vcGVuYmFua2luZ3Rlc3Qub3JnLnVr" +
+ "LzAwMTU4MDAwMDFIUVFyWkFBWC9yZXZva2VkLzlaekZGQnhTTEdFalBab2dSQWJ2RmQuandrcyIsInNvZnR3YXJlX3BvbGljeV" +
+ "91cmkiOiJodHRwczovL3d3dy5nb29nbGUuY29tIiwic29mdHdhcmVfdG9zX3VyaSI6Imh0dHBzOi8vd3d3Lmdvb2dsZS5jb20i" +
+ "LCJzb2Z0d2FyZV9vbl9iZWhhbGZfb2Zfb3JnIjpudWxsfQ.NLglx-H9D-i2f9GmSrxq00wTlKGHW_6zmKxGg_UhX0P0dzqJmNW" +
+ "UCDBdz-HhjlPSGeLqumyM_hJZELGv96p6CllmHdNA12gIGem3oBqnaPq9wfcr5Esn7sfRODPComjr6lKxNSXraLT7qpRHCJoxq" +
+ "yi72RH7T6HyF5lobTHWcZRkCNtc9cWJMKbftGCDSGRlO0XSYvvdGMDBCQT5-KiuKiWcKcBcFX2TLpTDDYaf-GNtATQ0O_vl266" +
+ "fDPyzG9XF6NLheG0ITrTBGuVN2JzSDC50_vCqR754LtFKNLXKQ2WTnrY3TgEBbyaKj3N0_YdDIuT442zkadg8lvoNpXyk4A";
+
+ PowerMockito.when(OpenBankingConfigParser.getInstance()
+ .getSoftwareEnvIdentificationSSAPropertyValueForSandbox()).thenReturn("sandbox");
+ PowerMockito.when(OpenBankingConfigParser.getInstance()
+ .getSoftwareEnvIdentificationSSAPropertyName()).thenReturn("software_environment");
+ String softwareEnvironmentFromSSA = OpenBankingUtils.getSoftwareEnvironmentFromSSA(prodSsa);
+ Assert.assertEquals(softwareEnvironmentFromSSA, IdentityConstants.PRODUCTION);
+ }
+
@Test
public void testDisputeDataWhenNonErrorPublishingEnabled() throws Exception {
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/dcr/DCRExecutor.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/dcr/DCRExecutor.java
index a86cedbd..f4c2e114 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/dcr/DCRExecutor.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/dcr/DCRExecutor.java
@@ -27,10 +27,10 @@
import com.wso2.openbanking.accelerator.common.constant.OpenBankingConstants;
import com.wso2.openbanking.accelerator.common.error.OpenBankingErrorCodes;
import com.wso2.openbanking.accelerator.common.exception.OpenBankingException;
-import com.wso2.openbanking.accelerator.common.identity.IdentityConstants;
import com.wso2.openbanking.accelerator.common.util.Generated;
import com.wso2.openbanking.accelerator.common.util.HTTPClientUtils;
import com.wso2.openbanking.accelerator.common.util.JWTUtils;
+import com.wso2.openbanking.accelerator.common.util.OpenBankingUtils;
import com.wso2.openbanking.accelerator.gateway.cache.GatewayCacheKey;
import com.wso2.openbanking.accelerator.gateway.executor.core.OpenBankingGatewayExecutor;
import com.wso2.openbanking.accelerator.gateway.executor.exception.OpenBankingExecutorException;
@@ -236,7 +236,7 @@ public void postProcessResponse(OBAPIResponseContext obapiResponseContext) {
//map keys to am application
JsonObject keyMapPayload = getKeyMapPayload(createdDCRAppDetails.get(clientIdParam).getAsString(),
createdSpDetails.getAsJsonObject().get(clientSecret).getAsString(),
- getSoftwareEnvironmentFromSSA(softwareStatement), keyManagerName);
+ OpenBankingUtils.getSoftwareEnvironmentFromSSA(softwareStatement), keyManagerName);
JsonElement amKeyMapResponse = callPost(keyMapURL, keyMapPayload.toString(),
GatewayConstants.BEARER_TAG.concat(token));
@@ -869,27 +869,6 @@ public List getRolesFromSSA(String softwareStatement) throws ParseExcept
return softwareRoleList;
}
- /**
- * Extract software_environment (SANDBOX or PRODUCTION) from SSA.
- *
- * @param softwareStatement software statement extracted from request payload
- * @return software_environment
- * @throws ParseException
- */
- public String getSoftwareEnvironmentFromSSA(String softwareStatement) throws ParseException {
-
- String softwareEnvironment = IdentityConstants.PRODUCTION;
- // decode software statement and get softwareEnvironment
- JSONObject softwareStatementBody = JWTUtils.decodeRequestJWT(softwareStatement, "body");
- Object softwareEnvironmentValue =
- softwareStatementBody.get(OpenBankingConstants.SOFTWARE_ENVIRONMENT);
- if (softwareEnvironmentValue != null &&
- softwareEnvironmentValue.toString().equalsIgnoreCase(IdentityConstants.SANDBOX)) {
- softwareEnvironment = IdentityConstants.SANDBOX;
- }
- return softwareEnvironment;
- }
-
protected String getApplicationName(String responsePayload, Map configurations)
throws ParseException {
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/java/com/wso2/openbanking/accelerator/gateway/executor/dcr/DCRExecutorTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/java/com/wso2/openbanking/accelerator/gateway/executor/dcr/DCRExecutorTest.java
index 144ea1a9..c0514a21 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/java/com/wso2/openbanking/accelerator/gateway/executor/dcr/DCRExecutorTest.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/java/com/wso2/openbanking/accelerator/gateway/executor/dcr/DCRExecutorTest.java
@@ -20,6 +20,7 @@
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
+import com.wso2.openbanking.accelerator.common.config.OpenBankingConfigParser;
import com.wso2.openbanking.accelerator.common.config.OpenBankingConfigurationService;
import com.wso2.openbanking.accelerator.common.constant.OpenBankingConstants;
import com.wso2.openbanking.accelerator.common.exception.OpenBankingException;
@@ -70,7 +71,7 @@
* Test for DCR executor.
*/
@PowerMockIgnore("jdk.internal.reflect.*")
-@PrepareForTest({IdentityUtil.class, GatewayDataHolder.class})
+@PrepareForTest({IdentityUtil.class, GatewayDataHolder.class, OpenBankingConfigParser.class})
public class DCRExecutorTest {
@Mock
@@ -85,6 +86,9 @@ public class DCRExecutorTest {
@Mock
APIManagerConfiguration apiManagerConfiguration;
+ @Mock
+ OpenBankingConfigParser openBankingConfigParser;
+
@InjectMocks
DCRExecutor dcrExecutor = new DCRExecutor();
@@ -392,6 +396,10 @@ public void testNewAPIsToSubscribe() {
@Test
public void testPostProcessResponseForRegister() throws Exception {
+ PowerMockito.mockStatic(OpenBankingConfigParser.class);
+ Mockito.when(OpenBankingConfigParser.getInstance()).thenReturn(openBankingConfigParser);
+ Mockito.when(OpenBankingConfigParser.getInstance()
+ .getSoftwareEnvIdentificationSSAPropertyValueForSandbox()).thenReturn("sandbox");
OBAPIResponseContext obapiResponseContext = Mockito.mock(OBAPIResponseContext.class);
MsgInfoDTO msgInfoDTO = Mockito.mock(MsgInfoDTO.class);
DCRExecutor dcrExecutor = Mockito.spy(DCRExecutor.class);
@@ -633,6 +641,10 @@ public void testErrorScenarios() throws IOException, OpenBankingException, URISy
Mockito.doReturn(dcrResponsePayload).when(obapiResponseContext).getResponsePayload();
Mockito.when(openBankingConfigurationService.getAllowedAPIs()).thenReturn(configuredAPIList);
+ PowerMockito.mockStatic(OpenBankingConfigParser.class);
+ Mockito.when(OpenBankingConfigParser.getInstance()).thenReturn(openBankingConfigParser);
+ Mockito.when(OpenBankingConfigParser.getInstance().getSoftwareEnvIdentificationSSAPropertyValueForSandbox())
+ .thenReturn("sandbox");
GatewayDataHolder.getInstance().setApiManagerConfiguration(apiManagerConfigurationService);
Mockito.when(apiManagerConfigurationService.getAPIManagerConfiguration()).thenReturn(apiManagerConfiguration);
Mockito.doReturn("admin").when(apiManagerConfiguration).getFirstProperty(anyString());
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/validation/SignatureValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/validation/SignatureValidator.java
index 6d53da5c..29091566 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/validation/SignatureValidator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/validation/SignatureValidator.java
@@ -20,7 +20,9 @@
import com.nimbusds.jose.JOSEException;
import com.nimbusds.jose.proc.BadJOSEException;
import com.nimbusds.jwt.SignedJWT;
+import com.wso2.openbanking.accelerator.common.identity.IdentityConstants;
import com.wso2.openbanking.accelerator.common.util.JWTUtils;
+import com.wso2.openbanking.accelerator.common.util.OpenBankingUtils;
import com.wso2.openbanking.accelerator.identity.dcr.validation.annotation.ValidateSignature;
import com.wso2.openbanking.accelerator.identity.internal.IdentityExtensionsDataHolder;
import org.apache.commons.beanutils.BeanUtils;
@@ -61,26 +63,27 @@ public boolean isValid(Object registrationRequest,
SignedJWT signedJWT = SignedJWT.parse(BeanUtils.getProperty(registrationRequest, softwareStatementPath));
String jwtString = signedJWT.getParsedString();
String alg = signedJWT.getHeader().getAlgorithm().getName();
+ String softwareEnvironmentFromSSA = OpenBankingUtils.getSoftwareEnvironmentFromSSA(jwtString);
+ String jwksURL;
- // first validate the signature against production jwks
- String jwksURL = IdentityExtensionsDataHolder.getInstance().getConfigurationMap()
- .get(DCRCommonConstants.DCR_JWKS_ENDPOINT_PRODUCTION).toString();
- if (log.isDebugEnabled()) {
- log.debug(String.format("Validating the signature from Production JwksUrl %s", jwksURL));
- }
- isValidSignature = isValidateJWTSignature(jwksURL, jwtString, alg);
-
- if (!isValidSignature) {
+ if (IdentityConstants.PRODUCTION.equals(softwareEnvironmentFromSSA)) {
+ // validate the signature against production jwks
+ jwksURL = IdentityExtensionsDataHolder.getInstance().getConfigurationMap()
+ .get(DCRCommonConstants.DCR_JWKS_ENDPOINT_PRODUCTION).toString();
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Validating the signature from Production JwksUrl %s",
+ jwksURL.replaceAll("[\r\n]", "")));
+ }
+ } else {
// else validate the signature against sandbox jwks
jwksURL = IdentityExtensionsDataHolder.getInstance().getConfigurationMap()
.get(DCRCommonConstants.DCR_JWKS_ENDPOINT_SANDBOX).toString();
if (log.isDebugEnabled()) {
- log.debug(String.format("Could not validate the signature from Production JwksUrl, " +
- "Trying with Sandbox JwksUrl %s", jwksURL));
+ log.debug(String.format("Validating the signature from Sandbox JwksUrl %s",
+ jwksURL.replaceAll("[\r\n]", "")));
}
- isValidSignature = isValidateJWTSignature(jwksURL, jwtString, alg);
}
- return isValidSignature;
+ return isValidateJWTSignature(jwksURL, jwtString, alg);
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
log.error("Error while resolving validation fields", e);
} catch (ParseException e) {
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/token/validators/SignatureAlgorithmEnforcementValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/token/validators/SignatureAlgorithmEnforcementValidator.java
index fae6735a..a7065b3b 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/token/validators/SignatureAlgorithmEnforcementValidator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/token/validators/SignatureAlgorithmEnforcementValidator.java
@@ -47,7 +47,8 @@ public void validate(ServletRequest request, String clientId) throws TokenFilter
if (request instanceof HttpServletRequest) {
String signedObject = request.getParameter(IdentityCommonConstants.OAUTH_JWT_ASSERTION);
- if (StringUtils.isNotEmpty(signedObject)) {
+ if (StringUtils.isNotEmpty(signedObject) &&
+ StringUtils.isNotEmpty(getRegisteredSigningAlgorithm(clientId))) {
validateInboundSignatureAlgorithm(getRequestSigningAlgorithm(signedObject),
getRegisteredSigningAlgorithm(clientId));
}
From 4558f2dd322484944be3dddfbc0b6cad1f78d31f Mon Sep 17 00:00:00 2001
From: hasithakn
Date: Wed, 8 Nov 2023 22:51:37 +0530
Subject: [PATCH 013/281] Fix checkstyle
---
.../openbanking/accelerator/common/util/OpenBankingUtils.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/OpenBankingUtils.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/OpenBankingUtils.java
index a2ddbaf9..669fa0ec 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/OpenBankingUtils.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/OpenBankingUtils.java
@@ -20,10 +20,10 @@
import com.wso2.openbanking.accelerator.common.config.OpenBankingConfigParser;
import com.wso2.openbanking.accelerator.common.exception.OpenBankingRuntimeException;
import com.wso2.openbanking.accelerator.common.identity.IdentityConstants;
+import net.minidev.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import net.minidev.json.JSONObject;
import java.lang.reflect.InvocationTargetException;
import java.text.ParseException;
From 62bb8c5bd9731b579ab69e11eb751a3848747978 Mon Sep 17 00:00:00 2001
From: hasithakn
Date: Thu, 9 Nov 2023 11:26:37 +0530
Subject: [PATCH 014/281] Fix PR comments
---
.../templates/repository/conf/open-banking.xml.j2 | 5 +++++
.../resources/wso2am-4.0.0-deployment.toml | 2 ++
.../resources/wso2am-4.1.0-deployment.toml | 2 ++
.../resources/wso2am-4.2.0-deployment.toml | 2 ++
.../templates/repository/conf/open-banking.xml.j2 | 5 +++++
.../resources/wso2is-5.11.0-deployment.toml | 2 ++
.../resources/wso2is-6.0.0-deployment.toml | 2 ++
.../resources/wso2is-6.1.0-deployment.toml | 2 ++
.../common/config/OpenBankingConfigParser.java | 12 ++++++++++++
.../common/constant/OpenBankingConstants.java | 2 ++
.../accelerator/common/util/OpenBankingUtils.java | 5 +++++
11 files changed, 41 insertions(+)
diff --git a/open-banking-accelerator/accelerators/ob-apim/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2 b/open-banking-accelerator/accelerators/ob-apim/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
index e26f6d73..92ee2255 100644
--- a/open-banking-accelerator/accelerators/ob-apim/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
+++ b/open-banking-accelerator/accelerators/ob-apim/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
@@ -313,6 +313,11 @@
{% else %}
sandbox
{% endif %}
+ {% if open_banking.dcr.registration.software_environment_identification.ssa_property_value_for_production is defined %}
+ {{open_banking.dcr.registration.software_environment_identification.ssa_property_value_for_production}}
+ {% else %}
+ production
+ {% endif %}
diff --git a/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.0.0-deployment.toml b/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.0.0-deployment.toml
index 42683bfc..ce52b689 100644
--- a/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.0.0-deployment.toml
+++ b/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.0.0-deployment.toml
@@ -433,7 +433,9 @@ roles = "AISP"
[open_banking.dcr.registration.software_environment_identification]
ssa_property_name = "software_environment"
+# If both below values doesnt match, Then software_environment is default to production.
ssa_property_value_for_sandbox = "sandbox"
+ssa_property_value_for_production = "production"
#============executors=========================
[[open_banking.gateway.openbanking_gateway_executors.type]]
diff --git a/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.1.0-deployment.toml b/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.1.0-deployment.toml
index 80e70a64..7d6e324a 100644
--- a/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.1.0-deployment.toml
+++ b/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.1.0-deployment.toml
@@ -433,7 +433,9 @@ roles = "AISP"
[open_banking.dcr.registration.software_environment_identification]
ssa_property_name = "software_environment"
+# If both below values doesnt match, Then software_environment is default to production.
ssa_property_value_for_sandbox = "sandbox"
+ssa_property_value_for_production = "production"
#============executors=========================
[[open_banking.gateway.openbanking_gateway_executors.type]]
diff --git a/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.2.0-deployment.toml b/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.2.0-deployment.toml
index 5fbe2415..a35ebf0c 100644
--- a/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.2.0-deployment.toml
+++ b/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.2.0-deployment.toml
@@ -437,7 +437,9 @@ roles = "AISP"
[open_banking.dcr.registration.software_environment_identification]
ssa_property_name = "software_environment"
+# If both below values doesnt match, Then software_environment is default to production.
ssa_property_value_for_sandbox = "sandbox"
+ssa_property_value_for_production = "production"
#============executors=========================
[[open_banking.gateway.openbanking_gateway_executors.type]]
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2 b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
index 7bbcdaac..443d0d31 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
@@ -466,6 +466,11 @@
{% else %}
sandbox
{% endif %}
+ {% if open_banking.dcr.registration.software_environment_identification.ssa_property_value_for_production is defined %}
+ {{open_banking.dcr.registration.software_environment_identification.ssa_property_value_for_production}}
+ {% else %}
+ production
+ {% endif %}
{% if open_banking.dcr.registration.grant_types.required is defined %}
diff --git a/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-5.11.0-deployment.toml b/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-5.11.0-deployment.toml
index 3c70545e..5db0a25c 100644
--- a/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-5.11.0-deployment.toml
+++ b/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-5.11.0-deployment.toml
@@ -408,7 +408,9 @@ name = "OpenBanking Ltd"
[open_banking.dcr.registration.software_environment_identification]
ssa_property_name = "software_environment"
+# If both below values doesnt match, Then software_environment is default to production.
ssa_property_value_for_sandbox = "sandbox"
+ssa_property_value_for_production = "production"
#Signature algorithm types that are allowed
#[[open_banking.signature_validation.allowed_algorithms]]
diff --git a/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-6.0.0-deployment.toml b/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-6.0.0-deployment.toml
index 133e0552..08eec470 100644
--- a/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-6.0.0-deployment.toml
+++ b/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-6.0.0-deployment.toml
@@ -408,7 +408,9 @@ name = "OpenBanking Ltd"
[open_banking.dcr.registration.software_environment_identification]
ssa_property_name = "software_environment"
+# If both below values doesnt match, Then software_environment is default to production.
ssa_property_value_for_sandbox = "sandbox"
+ssa_property_value_for_production = "production"
#Signature algorithm types that are allowed
#[[open_banking.signature_validation.allowed_algorithms]]
diff --git a/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-6.1.0-deployment.toml b/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-6.1.0-deployment.toml
index a14e9525..aab5c780 100644
--- a/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-6.1.0-deployment.toml
+++ b/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-6.1.0-deployment.toml
@@ -408,7 +408,9 @@ name = "OpenBanking Ltd"
[open_banking.dcr.registration.software_environment_identification]
ssa_property_name = "software_environment"
+# If both below values doesnt match, Then software_environment is default to production.
ssa_property_value_for_sandbox = "sandbox"
+ssa_property_value_for_production = "production"
#Signature algorithm types that are allowed
#[[open_banking.signature_validation.allowed_algorithms]]
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/config/OpenBankingConfigParser.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/config/OpenBankingConfigParser.java
index 776e8263..c3df4d3b 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/config/OpenBankingConfigParser.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/config/OpenBankingConfigParser.java
@@ -1419,6 +1419,18 @@ public String getSoftwareEnvIdentificationSSAPropertyValueForSandbox() {
OpenBankingConstants.DCR_SOFTWARE_ENV_IDENTIFICATION_VALUE_FOR_SANDBOX);
}
+ /**
+ * Method to get software environment identification value for production in SSA.
+ *
+ * @return String software environment identification value for production.
+ */
+ public String getSoftwareEnvIdentificationSSAPropertyValueForProduction() {
+ return getConfigElementFromKey(
+ OpenBankingConstants.DCR_SOFTWARE_ENV_IDENTIFICATION_VALUE_FOR_PRODUCTION) == null ?
+ "production" : (String) getConfigElementFromKey(
+ OpenBankingConstants.DCR_SOFTWARE_ENV_IDENTIFICATION_VALUE_FOR_PRODUCTION);
+ }
+
/**
* Get config related for checking whether PSU is a federated user or not.
*
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/constant/OpenBankingConstants.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/constant/OpenBankingConstants.java
index e29c00b9..6831a70c 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/constant/OpenBankingConstants.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/constant/OpenBankingConstants.java
@@ -66,6 +66,8 @@ public class OpenBankingConstants {
"DCR.RegistrationRequestParams.SoftwareEnvironmentIdentification.PropertyName";
public static final String DCR_SOFTWARE_ENV_IDENTIFICATION_VALUE_FOR_SANDBOX =
"DCR.RegistrationRequestParams.SoftwareEnvironmentIdentification.PropertyValueForSandbox";
+ public static final String DCR_SOFTWARE_ENV_IDENTIFICATION_VALUE_FOR_PRODUCTION =
+ "DCR.RegistrationRequestParams.SoftwareEnvironmentIdentification.PropertyValueForProduction";
public static final String APIM_APPCREATION = "DCR.APIMRESTEndPoints.AppCreation";
public static final String APIM_KEYGENERATION = "DCR.APIMRESTEndPoints.KeyGeneration";
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/OpenBankingUtils.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/OpenBankingUtils.java
index 669fa0ec..d8c68a9a 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/OpenBankingUtils.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/OpenBankingUtils.java
@@ -69,6 +69,8 @@ public static String getSoftwareEnvironmentFromSSA(String softwareStatement) thr
.getSoftwareEnvIdentificationSSAPropertyName();
String sandboxEnvIdentificationValue = OpenBankingConfigParser.getInstance()
.getSoftwareEnvIdentificationSSAPropertyValueForSandbox();
+ String prodEnvIdentificationValue = OpenBankingConfigParser.getInstance()
+ .getSoftwareEnvIdentificationSSAPropertyValueForProduction();
String softwareEnvironment = IdentityConstants.PRODUCTION;
// decode software statement and get softwareEnvironment
JSONObject softwareStatementBody = JWTUtils.decodeRequestJWT(softwareStatement, "body");
@@ -76,6 +78,9 @@ public static String getSoftwareEnvironmentFromSSA(String softwareStatement) thr
if (softwareEnvironmentValue != null &&
softwareEnvironmentValue.toString().equalsIgnoreCase(sandboxEnvIdentificationValue)) {
softwareEnvironment = IdentityConstants.SANDBOX;
+ } else if (softwareEnvironmentValue != null &&
+ softwareEnvironmentValue.toString().equalsIgnoreCase(prodEnvIdentificationValue)) {
+ softwareEnvironment = IdentityConstants.PRODUCTION;
}
return softwareEnvironment;
}
From cde0ef9d3216ab6b595d98a53eb3cd4006300d35 Mon Sep 17 00:00:00 2001
From: Ashirwada
Date: Thu, 16 Nov 2023 16:22:08 +0530
Subject: [PATCH 015/281] Fixed review comments
---
.../event-notifications/mssql.sql | 23 +++++++++++++++++
.../event-notifications/mysql.sql | 23 +++++++++++++++++
.../event-notifications/oracle.sql | 25 +++++++++++++++++--
.../event-notifications/postgresql.sql | 23 +++++++++++++++++
.../endpoint/api/EventPollingEndpoint.java | 2 +-
5 files changed, 93 insertions(+), 3 deletions(-)
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/mssql.sql b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/mssql.sql
index 6419446c..428f201f 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/mssql.sql
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/mssql.sql
@@ -1,3 +1,26 @@
+/**
+ * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+-- All the data related to time are stored in unix time stamp and therefore, the data types for the time related data
+-- are represented in BIGINT.
+-- Since the database systems does not support adding default unix time to the database columns, the default data
+-- storing is handled within the database querieS.
+
CREATE TABLE OB_NOTIFICATION (
NOTIFICATION_ID varchar(36) NOT NULL,
CLIENT_ID varchar(255) NOT NULL,
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/mysql.sql b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/mysql.sql
index fbbfa516..1da13b5c 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/mysql.sql
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/mysql.sql
@@ -1,3 +1,26 @@
+/**
+ * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+-- All the data related to time are stored in unix time stamp and therefore, the data types for the time related data
+-- are represented in BIGINT.
+-- Since the database systems does not support adding default unix time to the database columns, the default data
+-- storing is handled within the database querieS.
+
-- For event notifications feature run the following queries against the openbank_openbankingdb--
CREATE TABLE IF NOT EXISTS OB_NOTIFICATION (
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/oracle.sql b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/oracle.sql
index 176c0d97..ebab33d9 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/oracle.sql
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/oracle.sql
@@ -1,3 +1,26 @@
+/**
+ * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+-- All the data related to time are stored in unix time stamp and therefore, the data types for the time related data
+-- are represented in BIGINT.
+-- Since the database systems does not support adding default unix time to the database columns, the default data
+-- storing is handled within the database querieS.
+
CREATE TABLE OB_NOTIFICATION (
NOTIFICATION_ID varchar2(36) NOT NULL,
CLIENT_ID varchar2(255) NOT NULL,
@@ -52,5 +75,3 @@ CREATE TABLE OB_NOTIFICATION_SUBSCRIBED_EVENTS (
PRIMARY KEY (SUBSCRIPTION_ID, EVENT_TYPE),
CONSTRAINT FK_NotificationSubEvents FOREIGN KEY (SUBSCRIPTION_ID) REFERENCES OB_NOTIFICATION_SUBSCRIPTION(SUBSCRIPTION_ID)
);
-
-
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/postgresql.sql b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/postgresql.sql
index 971e6487..fb616f99 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/postgresql.sql
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/postgresql.sql
@@ -1,3 +1,26 @@
+/**
+ * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+-- All the data related to time are stored in unix time stamp and therefore, the data types for the time related data
+-- are represented in BIGINT.
+-- Since the database systems does not support adding default unix time to the database columns, the default data
+-- storing is handled within the database querieS.
+
-- For event notifications feature run the following queries against the openbank_openbankingdb--
CREATE TABLE IF NOT EXISTS OB_NOTIFICATION (
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/api/EventPollingEndpoint.java b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/api/EventPollingEndpoint.java
index dd39d1bf..d21b4a17 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/api/EventPollingEndpoint.java
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/api/EventPollingEndpoint.java
@@ -83,7 +83,7 @@ public Response pollEvents(@Context HttpServletRequest request, @Context HttpSer
eventPollingData = parameterMap.get(EventNotificationEndPointConstants.REQUEST).
toString().replaceAll("\\\\r|\\\\n|\\r|\\n|\\[|]| ", StringUtils.EMPTY);
- if (!eventPollingData.isEmpty()) {
+ if (!eventPollingData.isBlank()) {
byte[] decodedBytes = Base64.getDecoder().decode(eventPollingData);
String decodedString = new String(decodedBytes, StandardCharsets.UTF_8);
try {
From 0fd00a049bf4ad9ab40b8e36ea2b84df1c3228f3 Mon Sep 17 00:00:00 2001
From: Ashirwada Dayarathne
Date: Thu, 16 Nov 2023 16:23:31 +0530
Subject: [PATCH 016/281] Update
open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/oracle.sql
Co-authored-by: Chinthaka Jayatilake <37581983+ChinthakaJ98@users.noreply.github.com>
---
.../dbscripts/open-banking/event-notifications/oracle.sql | 1 -
1 file changed, 1 deletion(-)
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/oracle.sql b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/oracle.sql
index ebab33d9..478fb598 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/oracle.sql
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/event-notifications/oracle.sql
@@ -49,7 +49,6 @@ BEGIN
SELECT OB_NOTIFICATION_EVENT_seq.NEXTVAL INTO :NEW.EVENT_ID FROM DUAL;
END;
-
CREATE TABLE OB_NOTIFICATION_ERROR (
NOTIFICATION_ID varchar2(36) NOT NULL,
ERROR_CODE varchar2(255) NOT NULL,
From 2d4ee67d173ab4e17d4bdc0834e5e2bbed0bbba7 Mon Sep 17 00:00:00 2001
From: Ashirwada
Date: Thu, 16 Nov 2023 17:21:26 +0530
Subject: [PATCH 017/281] Fixed review comments
---
.../event/notifications/endpoint/api/EventPollingEndpoint.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/api/EventPollingEndpoint.java b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/api/EventPollingEndpoint.java
index d21b4a17..9ab95c6e 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/api/EventPollingEndpoint.java
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/api/EventPollingEndpoint.java
@@ -83,7 +83,7 @@ public Response pollEvents(@Context HttpServletRequest request, @Context HttpSer
eventPollingData = parameterMap.get(EventNotificationEndPointConstants.REQUEST).
toString().replaceAll("\\\\r|\\\\n|\\r|\\n|\\[|]| ", StringUtils.EMPTY);
- if (!eventPollingData.isBlank()) {
+ if (StringUtils.isNotBlank(eventPollingData)) {
byte[] decodedBytes = Base64.getDecoder().decode(eventPollingData);
String decodedString = new String(decodedBytes, StandardCharsets.UTF_8);
try {
From bae64bb42d6a2c11d06be787c8cb194397f433e3 Mon Sep 17 00:00:00 2001
From: Chinthaka Jayatilake <37581983+ChinthakaJ98@users.noreply.github.com>
Date: Fri, 17 Nov 2023 11:02:32 +0530
Subject: [PATCH 018/281] Adding ELK support for the OB Accelerator
---
.../repository/conf/open-banking.xml.j2 | 7 +++
.../resources/wso2am-4.0.0-deployment.toml | 3 +
.../resources/wso2am-4.1.0-deployment.toml | 3 +
.../resources/wso2am-4.2.0-deployment.toml | 3 +
.../repository/conf/open-banking.xml.j2 | 7 +++
.../resources/wso2is-5.11.0-deployment.toml | 3 +
.../resources/wso2is-6.0.0-deployment.toml | 3 +
.../resources/wso2is-6.1.0-deployment.toml | 3 +
.../common/util/AnalyticsLogsUtils.java | 58 +++++++++++++++++++
.../pom.xml | 10 ++++
.../constants/DataPublishingConstants.java | 1 +
.../common/util/OBDataPublisherUtil.java | 13 +++++
.../common/OBAnalyticsEventQueueTest.java | 39 ++++++++++++-
13 files changed, 151 insertions(+), 2 deletions(-)
create mode 100644 open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/AnalyticsLogsUtils.java
diff --git a/open-banking-accelerator/accelerators/ob-apim/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2 b/open-banking-accelerator/accelerators/ob-apim/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
index 92ee2255..e006744a 100644
--- a/open-banking-accelerator/accelerators/ob-apim/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
+++ b/open-banking-accelerator/accelerators/ob-apim/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
@@ -334,6 +334,13 @@
false
{% endif %}
+
+ {% if open_banking.analytics.elk is defined %}
+ {{open_banking.analytics.elk.enabled}}
+ {% else %}
+ false
+ {% endif %}
+
{% if open_banking.data_publishing.enable is defined %}
{{open_banking.data_publishing.enable}}
diff --git a/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.0.0-deployment.toml b/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.0.0-deployment.toml
index ce52b689..29ae8ffc 100644
--- a/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.0.0-deployment.toml
+++ b/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.0.0-deployment.toml
@@ -477,6 +477,9 @@ priority = 1000
[open_banking.apim.analytics]
enable=false
+[open_banking.analytics.elk]
+enabled = false
+
[open_banking.data_publishing]
enable = false
username="$ref{super_admin.username}@carbon.super"
diff --git a/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.1.0-deployment.toml b/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.1.0-deployment.toml
index 7d6e324a..4264444a 100644
--- a/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.1.0-deployment.toml
+++ b/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.1.0-deployment.toml
@@ -477,6 +477,9 @@ priority = 1000
[open_banking.apim.analytics]
enable=false
+[open_banking.analytics.elk]
+enabled = false
+
[open_banking.data_publishing]
enable = false
username="$ref{super_admin.username}@carbon.super"
diff --git a/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.2.0-deployment.toml b/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.2.0-deployment.toml
index a35ebf0c..13f005ff 100644
--- a/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.2.0-deployment.toml
+++ b/open-banking-accelerator/accelerators/ob-apim/repository/resources/wso2am-4.2.0-deployment.toml
@@ -481,6 +481,9 @@ priority = 1000
[open_banking.apim.analytics]
enable=false
+[open_banking.analytics.elk]
+enabled = false
+
[open_banking.data_publishing]
enable = false
username="$ref{super_admin.username}@carbon.super"
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2 b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
index 443d0d31..f9c86194 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
@@ -786,6 +786,13 @@
{{open_banking.sca.idp.step}}
{% endif %}
+
+ {% if open_banking.analytics.elk is defined %}
+ {{open_banking.analytics.elk.enabled}}
+ {% else %}
+ false
+ {% endif %}
+
{% if open_banking.data_publishing.enable is defined %}
{{open_banking.data_publishing.enable}}
diff --git a/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-5.11.0-deployment.toml b/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-5.11.0-deployment.toml
index 5db0a25c..2058ab3d 100644
--- a/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-5.11.0-deployment.toml
+++ b/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-5.11.0-deployment.toml
@@ -436,6 +436,9 @@ ssa_property_value_for_production = "production"
#required = false
#allowed_values = ["web"]
+[open_banking.analytics.elk]
+enabled = false
+
[open_banking.data_publishing]
enable = false
username="$ref{super_admin.username}@carbon.super"
diff --git a/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-6.0.0-deployment.toml b/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-6.0.0-deployment.toml
index 08eec470..2160f0ac 100644
--- a/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-6.0.0-deployment.toml
+++ b/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-6.0.0-deployment.toml
@@ -436,6 +436,9 @@ ssa_property_value_for_production = "production"
#required = false
#allowed_values = ["web"]
+[open_banking.analytics.elk]
+enabled = false
+
[open_banking.data_publishing]
enable = false
username="$ref{super_admin.username}@carbon.super"
diff --git a/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-6.1.0-deployment.toml b/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-6.1.0-deployment.toml
index aab5c780..1c5792ec 100644
--- a/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-6.1.0-deployment.toml
+++ b/open-banking-accelerator/accelerators/ob-is/repository/resources/wso2is-6.1.0-deployment.toml
@@ -436,6 +436,9 @@ ssa_property_value_for_production = "production"
#required = false
#allowed_values = ["web"]
+[open_banking.analytics.elk]
+enabled = false
+
[open_banking.data_publishing]
enable = false
username="$ref{super_admin.username}@carbon.super"
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/AnalyticsLogsUtils.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/AnalyticsLogsUtils.java
new file mode 100644
index 00000000..578e526c
--- /dev/null
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/AnalyticsLogsUtils.java
@@ -0,0 +1,58 @@
+/**
+ * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.openbanking.accelerator.common.util;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.wso2.openbanking.accelerator.common.exception.OpenBankingException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Map;
+
+/**
+ * Open Banking common utility class to publish analytics logs
+ */
+public class AnalyticsLogsUtils {
+
+ private static final Log log = LogFactory.getLog(AnalyticsLogsUtils.class);
+ private static final String LOG_FORMAT = "Data Stream : %s , Data Stream Version : %s , Data : {\"payload\":%s}";
+ private static final String DATA_PROCESSING_ERROR = "Error occurred while processing the analytics dataset";
+
+ /**
+ * Method to add analytics logs to the OB analytics log file
+ *
+ * @param logFile Name of the logger which is used to log analytics data to the log file
+ * @param dataStream Name of the data stream to which the data belongs
+ * @param dataVersion Version of the data stream to which the data belongs
+ * @param analyticsData Data which belongs to the given data stream that needs to be logged via the given logger
+ */
+ public static void addAnalyticsLogs (String logFile, String dataStream, String dataVersion, Map analyticsData) throws OpenBankingException {
+ Log customLog = LogFactory.getLog(logFile);
+ try {
+ customLog.info(String.format(LOG_FORMAT, dataStream,
+ dataVersion, new ObjectMapper().writeValueAsString(analyticsData)));
+ } catch (JsonProcessingException e) {
+ log.error(DATA_PROCESSING_ERROR);
+ throw new OpenBankingException(DATA_PROCESSING_ERROR, e);
+ }
+ }
+
+}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
index 6acfecf3..6bd7bc80 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
@@ -50,6 +50,16 @@
testngtest
+
+ org.powermock
+ powermock-module-testng
+ test
+
+
+ org.powermock
+ powermock-api-mockito
+ test
+ org.mockitomockito-all
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/src/main/java/com/wso2/openbanking/accelerator/data/publisher/common/constants/DataPublishingConstants.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/src/main/java/com/wso2/openbanking/accelerator/data/publisher/common/constants/DataPublishingConstants.java
index dcccccf7..5530fd44 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/src/main/java/com/wso2/openbanking/accelerator/data/publisher/common/constants/DataPublishingConstants.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/src/main/java/com/wso2/openbanking/accelerator/data/publisher/common/constants/DataPublishingConstants.java
@@ -31,6 +31,7 @@ public class DataPublishingConstants {
public static final String DATA_PUBLISHING_POOL_WAIT_TIME = "DataPublishing.PoolWaitTimeMs";
public static final String DATA_PUBLISHING_PROTOCOL = "DataPublishing.Protocol";
public static final String DATA_PUBLISHING_ENABLED = "DataPublishing.Enabled";
+ public static final String ELK_ANALYTICS_ENABLED = "ELKAnalytics.Enabled";
public static final String APIM_ANALYTICS_ENABLED = "APIMAnalytics.Enabled";
public static final String QUEUE_SIZE = "DataPublishing.QueueSize";
public static final String WORKER_THREAD_COUNT = "DataPublishing.WorkerThreadCount";
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/src/main/java/com/wso2/openbanking/accelerator/data/publisher/common/util/OBDataPublisherUtil.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/src/main/java/com/wso2/openbanking/accelerator/data/publisher/common/util/OBDataPublisherUtil.java
index 9a9b1414..884de1f3 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/src/main/java/com/wso2/openbanking/accelerator/data/publisher/common/util/OBDataPublisherUtil.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/src/main/java/com/wso2/openbanking/accelerator/data/publisher/common/util/OBDataPublisherUtil.java
@@ -18,6 +18,9 @@
package com.wso2.openbanking.accelerator.data.publisher.common.util;
+import com.wso2.openbanking.accelerator.common.config.OpenBankingConfigParser;
+import com.wso2.openbanking.accelerator.common.exception.OpenBankingException;
+import com.wso2.openbanking.accelerator.common.util.AnalyticsLogsUtils;
import com.wso2.openbanking.accelerator.data.publisher.common.DataPublisherPool;
import com.wso2.openbanking.accelerator.data.publisher.common.EventQueue;
import com.wso2.openbanking.accelerator.data.publisher.common.OpenBankingDataPublisher;
@@ -60,6 +63,16 @@ public static void releaseDataPublishingInstance(OpenBankingDataPublisher instan
*/
public static void publishData(String streamName, String streamVersion, Map analyticsData) {
+ // Analytics data will be added to the OB analytics logfile for processing if ELK is configured for the server.
+ if (Boolean.parseBoolean((String) OpenBankingConfigParser.getInstance().getConfiguration()
+ .get(DataPublishingConstants.ELK_ANALYTICS_ENABLED))) {
+ try {
+ AnalyticsLogsUtils.addAnalyticsLogs("OB_LOG", streamName, streamVersion, analyticsData);
+ } catch (OpenBankingException e) {
+ log.error("Error occurred while writing analytics logs", e);
+ }
+ }
+
if (Boolean.parseBoolean((String) OBAnalyticsDataHolder.getInstance().getConfigurationMap()
.get(DataPublishingConstants.DATA_PUBLISHING_ENABLED))) {
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/src/test/java/com/wso2/openbanking/accelerator/data/publisher/common/OBAnalyticsEventQueueTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/src/test/java/com/wso2/openbanking/accelerator/data/publisher/common/OBAnalyticsEventQueueTest.java
index 7c58ed41..522ca4ef 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/src/test/java/com/wso2/openbanking/accelerator/data/publisher/common/OBAnalyticsEventQueueTest.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/src/test/java/com/wso2/openbanking/accelerator/data/publisher/common/OBAnalyticsEventQueueTest.java
@@ -18,12 +18,22 @@
package com.wso2.openbanking.accelerator.data.publisher.common;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.wso2.openbanking.accelerator.common.config.OpenBankingConfigParser;
import com.wso2.openbanking.accelerator.common.config.OpenBankingConfigurationService;
+import com.wso2.openbanking.accelerator.common.exception.OpenBankingRuntimeException;
import com.wso2.openbanking.accelerator.data.publisher.common.internal.OBAnalyticsDataHolder;
import com.wso2.openbanking.accelerator.data.publisher.common.util.OBDataPublisherUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.mockito.Mock;
import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.testng.PowerMockTestCase;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -36,7 +46,12 @@
/**
* Open Banking analytics event queue test.
*/
-public class OBAnalyticsEventQueueTest {
+@PowerMockIgnore({"jdk.internal.reflect.*"})
+@PrepareForTest({OpenBankingConfigParser.class})
+public class OBAnalyticsEventQueueTest extends PowerMockTestCase {
+
+ @Mock
+ OpenBankingConfigParser openBankingConfigParser;
private static ByteArrayOutputStream outContent;
private static Logger logger = null;
@@ -45,6 +60,7 @@ public class OBAnalyticsEventQueueTest {
@BeforeClass
public void beforeTests() {
+ MockitoAnnotations.initMocks(this);
outContent = new ByteArrayOutputStream();
printStream = new PrintStream(outContent);
System.setOut(printStream);
@@ -59,6 +75,12 @@ public void testAddingDataToQueue() {
configs.put("DataPublishing.WorkerThreadCount", "3");
configs.put("DataPublishing.QueueSize", "10");
configs.put("DataPublishing.Enabled", "true");
+ configs.put("ELKAnalytics.Enabled", "true");
+
+ PowerMockito.mockStatic(OpenBankingConfigParser.class);
+ Mockito.when(OpenBankingConfigParser.getInstance())
+ .thenReturn(openBankingConfigParser);
+ Mockito.when(openBankingConfigParser.getConfiguration()).thenReturn(configs);
OpenBankingConfigurationService openBankingConfigurationService =
Mockito.mock(OpenBankingConfigurationService.class);
@@ -67,7 +89,14 @@ public void testAddingDataToQueue() {
OBAnalyticsDataHolder.getInstance().setOpenBankingConfigurationService(openBankingConfigurationService);
OBDataPublisherUtil.publishData("testStream", "1.0", configs);
- Assert.assertTrue(outContent.toString().isEmpty());
+ try {
+ Assert.assertTrue(outContent.toString().contains("Data Stream : testStream , Data Stream Version : 1.0 , " +
+ "Data : {\"payload\":" + new ObjectMapper().writeValueAsString(configs) + "}"));
+ Assert.assertFalse(outContent.toString().contains("Data publishing is disabled. " +
+ "Failed to obtain a data publisher instance."));
+ } catch (JsonProcessingException e) {
+ throw new OpenBankingRuntimeException("Error in processing JSON payload", e);
+ }
}
@Test
@@ -78,6 +107,12 @@ public void tryAddingToQueueWhenDataPublishingDisabled() {
configs.put("DataPublishing.WorkerThreadCount", "3");
configs.put("DataPublishing.QueueSize", "10");
configs.put("DataPublishing.Enabled", "false");
+ configs.put("ELKAnalytics.Enabled", "true");
+
+ PowerMockito.mockStatic(OpenBankingConfigParser.class);
+ Mockito.when(OpenBankingConfigParser.getInstance())
+ .thenReturn(openBankingConfigParser);
+ Mockito.when(openBankingConfigParser.getConfiguration()).thenReturn(configs);
OpenBankingConfigurationService openBankingConfigurationService =
Mockito.mock(OpenBankingConfigurationService.class);
From 7e9a89d5aa64e24a84ef4f76b15ff07a393d5f5f Mon Sep 17 00:00:00 2001
From: Chinthaka Jayatilake <37581983+ChinthakaJ98@users.noreply.github.com>
Date: Fri, 17 Nov 2023 14:20:46 +0530
Subject: [PATCH 019/281] Adding a constant
---
.../publisher/common/constants/DataPublishingConstants.java | 2 +-
.../data/publisher/common/util/OBDataPublisherUtil.java | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/src/main/java/com/wso2/openbanking/accelerator/data/publisher/common/constants/DataPublishingConstants.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/src/main/java/com/wso2/openbanking/accelerator/data/publisher/common/constants/DataPublishingConstants.java
index 5530fd44..30f8d7e1 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/src/main/java/com/wso2/openbanking/accelerator/data/publisher/common/constants/DataPublishingConstants.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/src/main/java/com/wso2/openbanking/accelerator/data/publisher/common/constants/DataPublishingConstants.java
@@ -35,7 +35,7 @@ public class DataPublishingConstants {
public static final String APIM_ANALYTICS_ENABLED = "APIMAnalytics.Enabled";
public static final String QUEUE_SIZE = "DataPublishing.QueueSize";
public static final String WORKER_THREAD_COUNT = "DataPublishing.WorkerThreadCount";
-
public static final String THRIFT_PUBLISHING_TIMEOUT = "DataPublishing.Thrift.PublishingTimeout";
+ public static final String LOG_FILE_NAME = "OB_LOG";
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/src/main/java/com/wso2/openbanking/accelerator/data/publisher/common/util/OBDataPublisherUtil.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/src/main/java/com/wso2/openbanking/accelerator/data/publisher/common/util/OBDataPublisherUtil.java
index 884de1f3..771b8d4d 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/src/main/java/com/wso2/openbanking/accelerator/data/publisher/common/util/OBDataPublisherUtil.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/src/main/java/com/wso2/openbanking/accelerator/data/publisher/common/util/OBDataPublisherUtil.java
@@ -67,7 +67,8 @@ public static void publishData(String streamName, String streamVersion, Map
Date: Fri, 17 Nov 2023 15:33:31 +0530
Subject: [PATCH 020/281] Update
open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/AnalyticsLogsUtils.java
Co-authored-by: Akram Azarm
---
.../openbanking/accelerator/common/util/AnalyticsLogsUtils.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/AnalyticsLogsUtils.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/AnalyticsLogsUtils.java
index 578e526c..736ba448 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/AnalyticsLogsUtils.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/AnalyticsLogsUtils.java
@@ -43,7 +43,7 @@ public class AnalyticsLogsUtils {
* @param dataVersion Version of the data stream to which the data belongs
* @param analyticsData Data which belongs to the given data stream that needs to be logged via the given logger
*/
- public static void addAnalyticsLogs (String logFile, String dataStream, String dataVersion, Map analyticsData) throws OpenBankingException {
Log customLog = LogFactory.getLog(logFile);
try {
From 0d2fca32b65c89325b70b53418359e5577564c5b Mon Sep 17 00:00:00 2001
From: kalpana
Date: Fri, 24 Nov 2023 13:44:43 +0530
Subject: [PATCH 021/281] VRP consent initiation flow implementation
---
.../repository/conf/open-banking.xml.j2 | 5 +
.../common/util/ErrorConstants.java | 14 +-
.../common/ConsentExtensionConstants.java | 34 +-
.../AcceleratorConsentExtensionFactory.java | 5 +
.../manage/impl/VRPConsentRequestHandler.java | 192 +++++++++
.../validator/VRPConsentRequestValidator.java | 288 +++++++++++++
.../extensions/util/ConsentManageUtil.java | 395 +++++++++++++++++-
7 files changed, 918 insertions(+), 15 deletions(-)
create mode 100644 open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/impl/VRPConsentRequestHandler.java
create mode 100644 open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/validator/VRPConsentRequestValidator.java
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2 b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
index 9b0a5cfa..e06fa574 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
@@ -206,6 +206,11 @@
{% else %}
https://localhost:8243/open-banking/{version}/cbpii/
{% endif %}
+ {% if open_banking.consent.vrp_consent_self_link is defined %}
+ {{open_banking.consent.vrp_consent_self_link}}
+ {% else %}
+ https://localhost:8243/open-banking/{version}/vrp/
+ {% endif %}
{% if open_banking.consent.data_retention.enabled is defined %}
{{open_banking.consent.data_retention.enabled}}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java
index 7f3ce859..182b4c35 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java
@@ -108,7 +108,6 @@ public class ErrorConstants {
public static final String PATH_CONSENT_ID = "Data.Initiation.Consent-id";
public static final String PATH_DATA = "Data";
public static final String PATH_INITIATION = "Data.Initiation";
- public static final String PATH_RISK = "Data.Risk";
public static final String PATH_URL = "Data.Url";
public static final String PATH_EXPIRATION_DATE = "Data.Expiration-Date";
public static final String MSG_MISSING_DEBTOR_ACC = "Mandatory parameter DebtorAccount is missing in the payload.";
@@ -207,9 +206,6 @@ public class ErrorConstants {
ErrorConstants.PATH_DATA;
public static final String INITIATION_NOT_FOUND = "Initiation is not found or empty in the request.:" +
ErrorConstants.PATH_INITIATION;
- public static final String RISK_MISMATCH = "RISK Does Not Match.:" + ErrorConstants.PATH_RISK;
- public static final String RISK_NOT_FOUND = "RISK is not found or empty in the request.:" +
- ErrorConstants.PATH_RISK;
public static final String INVALID_URI_ERROR = "Path requested is invalid. :" + ErrorConstants.PATH_URL;
public static final String COF_CONSENT_STATE_INVALID = "Confirmation of Funds validation failed due to invalid" +
" consent state.:" + ErrorConstants.PATH_STATUS;
@@ -221,9 +217,15 @@ public class ErrorConstants {
" retrieval request";
public static final String INVALID_CONSENT_ID = "Invalid Consent Id found in the request";
public static final String CONSENT_ID_NOT_FOUND = "Consent ID not available in consent data";
-
public static final String FIELD_INVALID_DATE = "OB.Field.InvalidDate";
public static final String EXPIRED_DATE_ERROR = "The ExpirationDateTime value has to be a future date.";
-
+ public static final String PATH_MAXIMUM_INDIVIDUAL_AMOUNT = "Data.ControlParameters.MaximumIndividualAmount.Amount";
+ public static final String INVALID_MAXIMUM_INDIVIDUAL_AMOUNT = "Invalid value for Amount in MaximumIndividualAmount";
+ public static final String INVALID_CURRENCY = "Invalid value for currency in MaximumIndividualAmount" ;
+ public static final String INVALID_PERIOD_ALIGNMENT = "Invalid value for period alignment in PeriodicLimits";
+ public static final String INVALID_PERIOD_TYPE = "Invalid value for period type in PeriodicLimits";
+ public static final String PATH_PERIOD_TYPE = "Data.ControlParameters.PeriodicLimits.PeriodType";
+ public static final String INVALID_VALID_TO_DATE = "Valid to Date specified in the request is invalid";
+ public static final String PATH_VALID_TO_DATE = "Data.ControlParameters.ValidToDateTime";
}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/ConsentExtensionConstants.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/ConsentExtensionConstants.java
index 6d02d829..f18db57b 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/ConsentExtensionConstants.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/ConsentExtensionConstants.java
@@ -48,6 +48,8 @@ public class ConsentExtensionConstants {
public static final String HTTP_CODE = "httpCode";
public static final String ERRORS = "errors";
public static final String PAYMENTS = "payments";
+ public static final String VRP = "vrp";
+
public static final String DATA = "Data";
public static final String INITIATION = "Initiation";
public static final String STATUS = "Status";
@@ -108,7 +110,6 @@ public class ConsentExtensionConstants {
public static final String OPENBANKING_INTENT_ID = "openbanking_intent_id";
public static final String VALUE = "value";
public static final String AUTHORIZED_STATUS = "authorised";
-
public static final String EXPIRATION_DATE = "ExpirationDateTime";
public static final String EXPIRATION_DATE_TITLE = "Expiration Date Time";
public static final String INSTRUCTED_AMOUNT_TITLE = "Instructed Amount";
@@ -121,8 +122,8 @@ public class ConsentExtensionConstants {
public static final String INSTRUCTION_IDENTIFICATION = "InstructionIdentification";
public static final String REJECTED_STATUS = "rejected";
public static final String OPEN_ENDED_AUTHORIZATION = "Open Ended Authorization Requested";
- public static final String DEBTOR_ACC_TITLE = "Debtor Account";
- public static final String SCHEME_NAME_TITLE = "Scheme Name";
+ public static final String DEBTOR_ACC_TITLE = "DebtorAccount";
+ public static final String SCHEME_NAME_TITLE = "SchemeName";
public static final String IDENTIFICATION_TITLE = "Identification";
public static final String NAME_TITLE = "Name";
public static final String SECONDARY_IDENTIFICATION_TITLE = "Secondary Identification";
@@ -153,19 +154,38 @@ public class ConsentExtensionConstants {
public static final String ACCOUNTS_SELF_LINK = "Consent.AccountAPIURL";
public static final String PAYMENT_SELF_LINK = "Consent.PaymentAPIURL";
public static final String COF_SELF_LINK = "Consent.FundsConfirmationAPIURL";
+ public static final String VRP_SELF_LINK = "Consent.VRPAPIURL";
public static final String REVOKED_STATUS = "revoked";
-
public static final String DISPLAY_NAME = "display_name";
public static final String ACCOUNT_DATA = "account_data";
public static final String SELECTED_ACCOUNT = "selectedAccount";
public static final String PAYMENT_COF_PATH = "funds-confirmation";
-
public static final String AWAITING_UPLOAD_STATUS = "awaitingUpload";
-
public static final String OB_REVOKED_STATUS = "Revoked";
public static final String OB_REJECTED_STATUS = "Rejected";
public static final String OB_AUTHORIZED_STATUS = "Authorised";
public static final String OB_AWAITING_AUTH_STATUS = "AwaitingAuthorisation";
public static final String OB_AWAITING_UPLOAD_STATUS = "AwaitingUpload";
-
+ public static final String VRP_CONSENT_PATH = "domestic-vrp-consents";
+ public static final String VRP_PAYMENT = "vrp-payment";
+ public static final String PAID_AMOUNT = "paid-amount";
+ public static final String LAST_PAYMENT_DATE = "last-payment-date";
+ public static final String AUTH_TYPE_AUTHORIZATION = "authorization";
+ public static final String CONTROL_PARAMETERS = "ControlParameters";
+ public static final String MAXIMUM_INDIVIDUAL_AMOUNT = "MaximumIndividualAmount";
+ public static final String PERIOD_ALIGNMENT = "PeriodicAlignment";
+ public static final String PERIODIC_LIMITS = "PeriodicLimits";
+ public static final String PERIOD_TYPE = "PeriodType";
+ public static final String PERIOD_AMOUNT_LIMIT = "Amount";
+ public static final String CONSENT = "consent-periodicAlignment";
+ public static final String CALENDER = "calender-periodicAlignment";
+ public static final String DAY = "Day";
+ public static final String WEEK = "Week";
+ public static final String FORTNIGHT = "Fortnight";
+ public static final String MONTH = "Month";
+ public static final String HALF_YEAR = "Half-year";
+ public static final String YEAR = "Year";
+ public static final String VALID_TO_DATE_TIME = "ValidToDateTime";
+ public static final String VALID_FROM_DATE_TIME = "ValidFromDateTime";
+ public static final String VRP_RESPONSE_PROCESS_PATH = "vrp-response-process";
}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/factory/AcceleratorConsentExtensionFactory.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/factory/AcceleratorConsentExtensionFactory.java
index ef849604..0c2197bd 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/factory/AcceleratorConsentExtensionFactory.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/factory/AcceleratorConsentExtensionFactory.java
@@ -30,6 +30,7 @@
import com.wso2.openbanking.accelerator.consent.extensions.manage.impl.CofConsentRequestHandler;
import com.wso2.openbanking.accelerator.consent.extensions.manage.impl.ConsentManageRequestHandler;
import com.wso2.openbanking.accelerator.consent.extensions.manage.impl.PaymentConsentRequestHandler;
+import com.wso2.openbanking.accelerator.consent.extensions.manage.impl.VRPConsentRequestHandler;
/**
* Factory class to get the class based in request type.
@@ -55,6 +56,10 @@ public static ConsentManageRequestHandler getConsentManageRequestValidator(Strin
case ConsentExtensionConstants.PAYMENT_CONSENT_PATH:
consentManageRequestHandler = new PaymentConsentRequestHandler();
break;
+ case ConsentExtensionConstants.VRP_CONSENT_PATH:
+ case ConsentExtensionConstants.VRP_RESPONSE_PROCESS_PATH:
+ consentManageRequestHandler = new VRPConsentRequestHandler();
+ break;
default:
return null;
}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/impl/VRPConsentRequestHandler.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/impl/VRPConsentRequestHandler.java
new file mode 100644
index 00000000..45ac82aa
--- /dev/null
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/impl/VRPConsentRequestHandler.java
@@ -0,0 +1,192 @@
+/**
+ * Copyright (c) 2021-2022, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
+ * This software is the property of WSO2 LLC. and its suppliers, if any.
+ * Dissemination of any information or reproduction of any material contained
+ * herein in any form is strictly forbidden, unless permitted by WSO2 expressly.
+ * You may not alter or remove any copyright or other notice from copies of this content.
+ */
+
+package com.wso2.openbanking.accelerator.consent.extensions.manage.impl;
+
+import com.wso2.openbanking.accelerator.common.exception.ConsentManagementException;
+import com.wso2.openbanking.accelerator.common.util.ErrorConstants;
+import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentException;
+import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentExtensionConstants;
+import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentExtensionUtils;
+import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentServiceUtil;
+import com.wso2.openbanking.accelerator.consent.extensions.common.ResponseStatus;
+import com.wso2.openbanking.accelerator.consent.extensions.internal.ConsentExtensionsDataHolder;
+import com.wso2.openbanking.accelerator.consent.extensions.manage.model.ConsentManageData;
+import com.wso2.openbanking.accelerator.consent.extensions.manage.validator.VRPConsentRequestValidator;
+import com.wso2.openbanking.accelerator.consent.extensions.util.ConsentManageUtil;
+import com.wso2.openbanking.accelerator.consent.mgt.dao.models.ConsentResource;
+import com.wso2.openbanking.accelerator.consent.mgt.dao.models.DetailedConsentResource;
+import net.minidev.json.JSONArray;
+import net.minidev.json.JSONObject;
+import net.minidev.json.parser.JSONParser;
+import net.minidev.json.parser.ParseException;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static com.wso2.openbanking.accelerator.consent.extensions.common.ConsentExtensionConstants.AUTH_TYPE_AUTHORIZATION;
+import static com.wso2.openbanking.accelerator.consent.extensions.common.ConsentExtensionConstants.CREATED_STATUS;
+
+/**
+ * Consent Manage request handler class for VRP Payment Request Validation.
+ */
+public class VRPConsentRequestHandler implements ConsentManageRequestHandler {
+
+ private static final Log log = LogFactory.getLog(VRPConsentRequestHandler.class);
+
+ /**
+ * Method to handle Variable Recurring Payment Consent Manage Post Request.
+ *
+ * @param consentManageData Object containing request details
+ */
+ @Override
+ public void handleConsentManagePost(ConsentManageData consentManageData) {
+
+ try {
+ //Validate cutoff datetime
+ if (ConsentExtensionUtils.shouldInitiationRequestBeRejected()) {
+ log.error(ErrorConstants.MSG_ELAPSED_CUT_OFF_DATE_TIME);
+ throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.PAYMENT_INITIATION_HANDLE_ERROR);
+ }
+
+ //Get the request payload from the ConsentManageData
+ Object request = consentManageData.getPayload();
+ if (!(request instanceof JSONObject)) {
+ log.error(ErrorConstants.PAYLOAD_FORMAT_ERROR);
+ throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.INVALID_REQ_PAYLOAD);
+ }
+
+ JSONObject requestObject = (JSONObject) request;
+
+ //Set request object to the response
+ JSONObject response = requestObject;
+
+ //Check Idempotency key exists
+ if (StringUtils.isEmpty(consentManageData.getHeaders()
+ .get(ConsentExtensionConstants.X_IDEMPOTENCY_KEY))) {
+ throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.IDEMPOTENCY_KEY_NOT_FOUND);
+ }
+
+ //Handle payment initiation flows
+ handlePaymentPost(consentManageData, requestObject, response);
+
+ } catch (ConsentManagementException e) {
+ log.error(e.getMessage());
+ throw new ConsentException(ResponseStatus.INTERNAL_SERVER_ERROR,
+ ErrorConstants.PAYMENT_INITIATION_HANDLE_ERROR);
+ }
+ }
+
+
+ @Override
+ public void handleConsentManageGet(ConsentManageData consentManageData) {
+
+ String consentId = consentManageData.getRequestPath().split("/")[1];
+ if (ConsentManageUtil.isConsentIdValid(consentId)) {
+ try {
+ ConsentResource consent = ConsentServiceUtil.getConsentService().getConsent(consentId,
+ false);
+ if (consent == null) {
+ throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.RESOURCE_CONSENT_MISMATCH);
+ }
+ // Check whether the client id is matching
+ if (!consent.getClientID().equals(consentManageData.getClientId())) {
+ //Throwing same error as null scenario since client will not be able to identify if consent
+ // exists if consent does not belong to them
+ throw new ConsentException(ResponseStatus.BAD_REQUEST,
+ ErrorConstants.NO_CONSENT_FOR_CLIENT_ERROR);
+ }
+ JSONObject receiptJSON = (JSONObject) new JSONParser(JSONParser.MODE_PERMISSIVE).
+ parse(consent.getReceipt());
+ consentManageData.setResponsePayload(ConsentManageUtil
+ .getInitiationRetrievalResponse(receiptJSON, consent, consentManageData,
+ ConsentExtensionConstants.VRP));
+ consentManageData.setResponseStatus(ResponseStatus.OK);
+ } catch (ConsentManagementException | ParseException e) {
+ throw new ConsentException(ResponseStatus.INTERNAL_SERVER_ERROR,
+ ErrorConstants.ACC_INITIATION_RETRIEVAL_ERROR);
+ }
+ } else {
+ throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.INVALID_CONSENT_ID);
+ }
+ }
+
+ @Override
+ public void handleConsentManageDelete(ConsentManageData consentManageData) {
+
+ ConsentManageUtil.handleConsentManageDelete(consentManageData);
+ }
+
+ /**
+ * Method to handle the Variable Recurring Payment POST requests.
+ *
+ * @param consentManageData Object containing request details
+ * @param requestObject Request payload
+ * @param response Response
+ */
+ private void handlePaymentPost(ConsentManageData consentManageData, JSONObject requestObject, JSONObject response)
+ throws ConsentManagementException {
+
+ DetailedConsentResource createdConsent;
+
+ //Validate Payment Initiation request
+ JSONObject validationResponse = VRPConsentRequestValidator.validatePaymentInitiation(requestObject);
+
+ //Throw an error if the initiation payload is not valid
+ if (!((boolean) validationResponse.get(ConsentExtensionConstants.IS_VALID))) {
+
+ log.error(ErrorConstants.PAYLOAD_INVALID);
+ throw new ConsentException((ResponseStatus) validationResponse
+ .get(ConsentExtensionConstants.HTTP_CODE),
+ String.valueOf(validationResponse.get(ConsentExtensionConstants.ERRORS)));
+ }
+
+ ConsentResource requestedConsent = new ConsentResource(consentManageData.getClientId(),
+ requestObject.toJSONString(), ConsentExtensionConstants.VRP,
+ ConsentExtensionConstants.AWAITING_AUTH_STATUS);
+
+ createdConsent = ConsentExtensionsDataHolder.getInstance().getConsentCoreService()
+ .createAuthorizableConsent(requestedConsent, null,
+ CREATED_STATUS, AUTH_TYPE_AUTHORIZATION, true);
+
+ //Set consent attributes for storing
+ Map consentAttributes = new HashMap();
+ consentAttributes.put(ConsentExtensionConstants.IDEMPOTENCY_KEY, consentManageData.getHeaders()
+ .get(ConsentExtensionConstants.X_IDEMPOTENCY_KEY));
+ //Store consent attributes
+ ConsentServiceUtil.getConsentService().storeConsentAttributes(createdConsent.getConsentID(),
+ consentAttributes);
+ consentManageData.setResponsePayload(ConsentManageUtil.getInitiationResponse(response, createdConsent,
+ consentManageData, ConsentExtensionConstants.VRP_PAYMENT));
+
+ //Set Control Parameters as consent attributes to store
+ JSONObject controlParameters = (JSONObject) ((JSONObject) ((JSONObject) consentManageData.getPayload())
+ .get(ConsentExtensionConstants.DATA)).get(ConsentExtensionConstants.CONTROL_PARAMETERS);
+ consentAttributes.put(ConsentExtensionConstants.MAXIMUM_INDIVIDUAL_AMOUNT, ((JSONObject) (controlParameters)
+ .get(ConsentExtensionConstants.MAXIMUM_INDIVIDUAL_AMOUNT)).get(ConsentExtensionConstants.AMOUNT)
+ .toString());
+ consentAttributes.put(ConsentExtensionConstants.PERIOD_TYPE, ((JSONObject) ((JSONArray) (controlParameters)
+ .get(ConsentExtensionConstants.PERIODIC_LIMITS)).get(0)).get(ConsentExtensionConstants.PERIOD_TYPE)
+ .toString());
+ consentAttributes.put(ConsentExtensionConstants.PERIOD_AMOUNT_LIMIT, ((JSONObject)
+ ((JSONArray) (controlParameters).get(ConsentExtensionConstants.PERIODIC_LIMITS)).get(0))
+ .get(ConsentExtensionConstants.PERIOD_AMOUNT_LIMIT).toString());
+ consentAttributes.put(ConsentExtensionConstants.PAID_AMOUNT, "0");
+ consentAttributes.put(ConsentExtensionConstants.LAST_PAYMENT_DATE, "0");
+
+ Map headers = consentManageData.getHeaders();
+ //Setting response headers
+ //Setting created time and idempotency to headers to handle idempotency in Gateway
+ consentManageData.setResponseHeader(ConsentExtensionConstants.X_IDEMPOTENCY_KEY,
+ headers.get(ConsentExtensionConstants.X_IDEMPOTENCY_KEY));
+ consentManageData.setResponseStatus(ResponseStatus.CREATED);
+ }
+}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/validator/VRPConsentRequestValidator.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/validator/VRPConsentRequestValidator.java
new file mode 100644
index 00000000..0bb6bae1
--- /dev/null
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/validator/VRPConsentRequestValidator.java
@@ -0,0 +1,288 @@
+/**
+ * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.com). All Rights Reserved.
+ *
+ * This software is the property of WSO2 Inc. and its suppliers, if any.
+ * Dissemination of any information or reproduction of any material contained
+ * herein is strictly forbidden, unless permitted by WSO2 in accordance with
+ * the WSO2 Software License available at https://wso2.com/licenses/eula/3.1.
+ * For specific language governing the permissions and limitations under this
+ * license, please see the license as well as any agreement you’ve entered into
+ * with WSO2 governing the purchase of this software and any associated services.
+ */
+
+package com.wso2.openbanking.accelerator.consent.extensions.manage.validator;
+import com.wso2.openbanking.accelerator.common.util.ErrorConstants;
+import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentExtensionConstants;
+import com.wso2.openbanking.accelerator.consent.extensions.common.ResponseStatus;
+import com.wso2.openbanking.accelerator.consent.extensions.util.ConsentManageUtil;
+import net.minidev.json.JSONArray;
+import net.minidev.json.JSONObject;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.time.OffsetDateTime;
+import java.util.Iterator;
+
+
+/**
+ * Consent Manage validator class for Variable Recurring Payment Request Validation.
+ */
+public class VRPConsentRequestValidator {
+
+ private static final Log log = LogFactory.getLog(VRPConsentRequestValidator.class);
+
+ public static final String MAXIMUM_INDIVIDUAL_AMOUNT_NOT_FOUND = "Instructed Amount isn't present in the payload";
+
+ public static final String PATH_MAXIMUM_INDIVIDUAL_CURRENCY = "Data.ControlParameters." +
+ "MaximumIndividualAmount.Currency";
+
+ public static final String MAXIMUM_INDIVIDUAL_AMOUNT_CURRENCY_NOT_FOUND = "Instructed currency isn't " +
+ "present in the payload";
+
+ public static final String INVALID_PERIOD_ALIGNMENT = "Invalid value for period alignment in PeriodicLimits";
+
+ public static final String PATH_PERIOD_ALIGNMENT = "Data.ControlParameters.PeriodLimits.PeriodAlignment";
+
+ /**
+ * Method to validate variable recurring payment control parameters.
+ *
+ * @param controlParameters Initiation Object
+ * @return validation response object
+ */
+ public static JSONObject validatecontrolParameters(JSONObject controlParameters) {
+ JSONObject validationResponse = new JSONObject();
+
+ //Validate Maximum individual amount in control parameters
+ if (controlParameters.containsKey(ConsentExtensionConstants.MAXIMUM_INDIVIDUAL_AMOUNT)) {
+ JSONObject maximumIndividualAmount = (JSONObject) controlParameters
+ .get(ConsentExtensionConstants.MAXIMUM_INDIVIDUAL_AMOUNT);
+ Object amount = maximumIndividualAmount.get(ConsentExtensionConstants.AMOUNT);
+ Object currency = maximumIndividualAmount.get(ConsentExtensionConstants.CURRENCY);
+
+ // validate amount
+ if (!ConsentManageUtil.validateAmount(maximumIndividualAmount)) {
+ log.error(ErrorConstants.INVALID_MAXIMUM_INDIVIDUAL_AMOUNT);
+ return ConsentManageUtil.getValidationResponse(ErrorConstants.FIELD_INVALID,
+ ErrorConstants.INVALID_MAXIMUM_INDIVIDUAL_AMOUNT,
+ ErrorConstants.PATH_MAXIMUM_INDIVIDUAL_AMOUNT);
+ }
+
+ if (amount == null || StringUtils.isEmpty(amount.toString())) {
+ log.error(MAXIMUM_INDIVIDUAL_AMOUNT_NOT_FOUND);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS, MAXIMUM_INDIVIDUAL_AMOUNT_NOT_FOUND);
+ return validationResponse;
+ }
+
+ //validate currency
+ if (!ConsentManageUtil.validateCurrency(maximumIndividualAmount)) {
+ log.error(ErrorConstants.INVALID_CURRENCY);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS,
+ ErrorConstants.PATH_MAXIMUM_INDIVIDUAL_AMOUNT);
+ return ConsentManageUtil.getValidationResponse(ErrorConstants.FIELD_INVALID,
+ ErrorConstants.INVALID_CURRENCY, ErrorConstants.PATH_MAXIMUM_INDIVIDUAL_AMOUNT);
+ }
+
+ if (currency == null || StringUtils.isEmpty(currency.toString())) {
+ log.error(MAXIMUM_INDIVIDUAL_AMOUNT_CURRENCY_NOT_FOUND);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS,
+ MAXIMUM_INDIVIDUAL_AMOUNT_CURRENCY_NOT_FOUND);
+ return validationResponse;
+ }
+ }
+
+ //Validate RequestedExecutionDateTime in controlParameters
+ if (controlParameters.containsKey(ConsentExtensionConstants.VALID_TO_DATE_TIME)) {
+
+ String validTo = controlParameters.getAsString(ConsentExtensionConstants.VALID_TO_DATE_TIME);
+ String validFrom = controlParameters.getAsString(ConsentExtensionConstants.VALID_FROM_DATE_TIME);
+
+ OffsetDateTime validToDateTime = OffsetDateTime.parse(validTo);
+ OffsetDateTime validFromDateTime = OffsetDateTime.parse(validFrom);
+ OffsetDateTime currentDateTime = OffsetDateTime.now(validToDateTime.getOffset());
+
+ //If the ValidToDAte is older than current date OR ValidToDAte is older than ValidFromDAte, return error
+ if (currentDateTime.isAfter(validToDateTime) || validFromDateTime.isAfter(validToDateTime)) {
+ log.error(ErrorConstants.INVALID_VALID_TO_DATE);
+ return ConsentManageUtil.getValidationResponse(ErrorConstants.FIELD_INVALID,
+ ErrorConstants.INVALID_VALID_TO_DATE, ErrorConstants.PATH_VALID_TO_DATE);
+ }
+ }
+
+ //Validate periodic limits in control parameters
+ if (controlParameters.containsKey(ConsentExtensionConstants.PERIODIC_LIMITS)) {
+ JSONArray periodicLimits = (JSONArray) controlParameters.get(ConsentExtensionConstants.PERIODIC_LIMITS);
+ Iterator it = periodicLimits.iterator();
+
+ while (it.hasNext()) {
+ JSONObject limit = (JSONObject) it.next();
+
+ Object amount = limit.get(ConsentExtensionConstants.AMOUNT);
+ Object currency = limit.get(ConsentExtensionConstants.CURRENCY);
+ Object periodType = limit.get(ConsentExtensionConstants.PERIOD_TYPE);
+
+ // validate amount
+ if (!ConsentManageUtil.validateAmount(limit)) {
+ log.error(ErrorConstants.INVALID_MAXIMUM_INDIVIDUAL_AMOUNT);
+ return ConsentManageUtil.getValidationResponse(ErrorConstants.FIELD_INVALID,
+ ErrorConstants.INVALID_MAXIMUM_INDIVIDUAL_AMOUNT,
+ ErrorConstants.PATH_MAXIMUM_INDIVIDUAL_AMOUNT);
+ }
+
+ if (amount == null || StringUtils.isEmpty(amount.toString())) {
+ log.error(MAXIMUM_INDIVIDUAL_AMOUNT_NOT_FOUND);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS,
+ MAXIMUM_INDIVIDUAL_AMOUNT_NOT_FOUND);
+ return validationResponse;
+ }
+
+ //validate currency
+ if (!ConsentManageUtil.validateCurrency(limit)) {
+ log.error(ErrorConstants.INVALID_CURRENCY);
+ return ConsentManageUtil.getValidationResponse(ErrorConstants.FIELD_INVALID,
+ ErrorConstants.INVALID_CURRENCY, ErrorConstants.PATH_MAXIMUM_INDIVIDUAL_AMOUNT);
+ }
+
+ if (currency == null || StringUtils.isEmpty(currency.toString())) {
+ log.error(MAXIMUM_INDIVIDUAL_AMOUNT_CURRENCY_NOT_FOUND);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS,
+ MAXIMUM_INDIVIDUAL_AMOUNT_CURRENCY_NOT_FOUND);
+ return validationResponse;
+ }
+
+ //validate period alignment
+ if (ConsentManageUtil.validatePeriodicAlignment(limit)) {
+ log.error(ErrorConstants.INVALID_PERIOD_ALIGNMENT);
+ return ConsentManageUtil.getValidationResponse(ErrorConstants.FIELD_INVALID,
+ INVALID_PERIOD_ALIGNMENT, PATH_PERIOD_ALIGNMENT);
+ }
+
+ //validate period type
+ if (!ConsentManageUtil.validatePeriodicType(limit)) {
+ log.error(ErrorConstants.INVALID_PERIOD_TYPE);
+ return ConsentManageUtil.getValidationResponse(ErrorConstants.FIELD_INVALID,
+ ErrorConstants.INVALID_PERIOD_TYPE, ErrorConstants.PATH_PERIOD_TYPE);
+ }
+
+ if (periodType == null || StringUtils.isEmpty(periodType.toString())) {
+ log.error(ErrorConstants.INVALID_PERIOD_TYPE);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS, ErrorConstants.INVALID_PERIOD_TYPE);
+ return validationResponse;
+ }
+ }
+
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, true);
+ return validationResponse;
+ }
+ return validationResponse;
+ }
+
+ /**
+ * Method to validate variable recurring payment initiation request.
+ *
+ * @param initiation Initiation Object
+ * @return validation response object
+ */
+ public static JSONObject validatePaymentInitiation(JSONObject initiation) {
+
+ JSONObject validationResponse = new JSONObject();
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+
+ //Check request body is valid and not empty
+ JSONObject dataValidationResult = ConsentManageUtil.validateInitiationDataBody(initiation);
+ if (!(boolean) dataValidationResult.get(ConsentExtensionConstants.IS_VALID)) {
+ return dataValidationResult;
+ }
+
+ JSONObject data = (JSONObject) initiation.get(ConsentExtensionConstants.DATA);
+
+ //Validate initiation in the VRP payload
+ if (data.containsKey(ConsentExtensionConstants.INITIATION)) {
+ JSONObject initiationValidationResult = VRPConsentRequestValidator
+ .validateVRPInitiationPayload((JSONObject) data.get(ConsentExtensionConstants.INITIATION));
+
+ if (!(boolean) initiationValidationResult.get(ConsentExtensionConstants.IS_VALID)) {
+ return initiationValidationResult;
+ }
+ } else {
+ log.error(ErrorConstants.PAYLOAD_FORMAT_ERROR);
+ return ConsentManageUtil.getValidationResponse(ErrorConstants.RESOURCE_INVALID_FORMAT,
+ ErrorConstants.PAYLOAD_FORMAT_ERROR, ErrorConstants.PATH_REQUEST_BODY);
+ }
+
+ //Validate the ControlParameter in the payload
+ if (data.containsKey(ConsentExtensionConstants.CONTROL_PARAMETERS)) {
+ JSONObject controlParameterValidationResult =
+ VRPConsentRequestValidator.validatecontrolParameters((JSONObject)
+ data.get(ConsentExtensionConstants.CONTROL_PARAMETERS));
+
+ if (!(boolean) controlParameterValidationResult.get(ConsentExtensionConstants.IS_VALID)) {
+ return controlParameterValidationResult;
+ }
+ } else {
+ log.error(ErrorConstants.PAYLOAD_FORMAT_ERROR);
+ return ConsentManageUtil.getValidationResponse(ErrorConstants.RESOURCE_INVALID_FORMAT,
+ ErrorConstants.PAYLOAD_FORMAT_ERROR, ErrorConstants.PATH_REQUEST_BODY);
+ }
+
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, true);
+ return validationResponse;
+ }
+
+
+ /**
+ * Validator class to validate variable recurring payment initiation payload.
+ * @param initiation
+ * @return validationResponse
+ */
+ public static JSONObject validateVRPInitiationPayload(JSONObject initiation) {
+
+ JSONObject validationResponse = new JSONObject();
+
+ //Validate DebtorAccount
+ if (initiation.containsKey(ConsentExtensionConstants.DEBTOR_ACC)) {
+
+ JSONObject debtorAccount = (JSONObject) initiation.get(ConsentExtensionConstants.DEBTOR_ACC);
+ JSONObject validationResult = ConsentManageUtil.validateVRPDebtorAccount(debtorAccount);
+
+ if (!(boolean) validationResult.get(ConsentExtensionConstants.IS_VALID)) {
+ return validationResult;
+ }
+ }
+
+ //Validate CreditorAccount
+ if (initiation.containsKey(ConsentExtensionConstants.CREDITOR_ACC)) {
+ JSONObject creditorAccount = (JSONObject) initiation.get(ConsentExtensionConstants.CREDITOR_ACC);
+
+ JSONObject validationResult = ConsentManageUtil.validateVRPCreditorAccount(creditorAccount);
+
+ if (!(boolean) validationResult.get(ConsentExtensionConstants.IS_VALID)) {
+ return validationResult;
+ }
+ }
+
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, true);
+ return validationResponse;
+ }
+
+}
+
+
+
+
+
+
+
+
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/util/ConsentManageUtil.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/util/ConsentManageUtil.java
index 5506c011..717e0af9 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/util/ConsentManageUtil.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/util/ConsentManageUtil.java
@@ -30,6 +30,8 @@
import com.wso2.openbanking.accelerator.consent.mgt.dao.models.ConsentResource;
import com.wso2.openbanking.accelerator.consent.mgt.dao.models.DetailedConsentResource;
import net.minidev.json.JSONObject;
+import net.minidev.json.parser.JSONParser;
+import net.minidev.json.parser.ParseException;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -42,6 +44,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
+import java.util.List;
import java.util.regex.Pattern;
/**
@@ -153,7 +156,7 @@ public static JSONObject validateDebtorAccount(JSONObject debtorAccount) {
log.error(ErrorConstants.INVALID_DEBTOR_ACC_IDENTIFICATION);
validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
- validationResponse.put(ConsentExtensionConstants.ERRORS, ErrorConstants.INVALID_DEBTOR_ACC_IDENTIFICATION);
+ validationResponse.put(ConsentExtensionConstants.ERRORS, ErrorConstants.MISSING_DEBTOR_ACC_IDENTIFICATION);
return validationResponse;
}
@@ -320,7 +323,6 @@ public static void handleConsentManageDelete(ConsentManageData consentManageData
Boolean shouldRevokeTokens;
if (ConsentManageUtil.isConsentIdValid(consentId)) {
try {
-
ConsentResource consentResource = ConsentExtensionsDataHolder.getInstance().getConsentCoreService()
.getConsent(consentId, false);
@@ -585,6 +587,9 @@ public static String constructSelfLink(String consentId, ConsentManageData conse
} else if (ConsentExtensionConstants.FUNDSCONFIRMATIONS.equals(type)) {
baseUrl = (String) parser.getConfiguration().get(
ConsentExtensionConstants.COF_SELF_LINK);
+ } else if (ConsentExtensionConstants.VRP.equals(type)) {
+ baseUrl = (String) parser.getConfiguration().get(
+ ConsentExtensionConstants.VRP_SELF_LINK);
}
String requestPath = consentManageData.getRequestPath();
@@ -621,4 +626,390 @@ public static boolean isConsentExpirationTimeValid(String expDateVal) {
}
}
+ /**
+ * validate the maximum amount in the payload in VRP.
+ */
+ public static boolean validateAmount(JSONObject maximumIndividualAmount) {
+ return (maximumIndividualAmount != null && maximumIndividualAmount
+ .containsKey(ConsentExtensionConstants.AMOUNT));
+ }
+
+ /**
+ * validate the currency in the payload in VRP.
+ */
+ public static boolean validateCurrency(JSONObject maximumIndividualAmount) {
+ return (maximumIndividualAmount != null && maximumIndividualAmount
+ .containsKey(ConsentExtensionConstants.CURRENCY));
+ }
+
+ /**
+ * validate the periodiclimits in the payload in VRP.
+ */
+ public static boolean validatePeriodicAlignment(JSONObject periodiclimit) {
+ String periodAlignment = (String) periodiclimit.get(ConsentExtensionConstants.PERIOD_ALIGNMENT);
+
+ return (ConsentExtensionConstants.CONSENT.equals(periodAlignment) ||
+ ConsentExtensionConstants.CALENDER.equals(periodAlignment));
+ }
+
+ /**
+ * method to validate periodic type in VRP.
+ */
+ public static boolean validatePeriodicType(JSONObject periodiclimit) {
+ String periodType = (String) periodiclimit.get(ConsentExtensionConstants.PERIOD_TYPE);
+
+ List periodTypes = Arrays.asList(ConsentExtensionConstants.DAY,
+ ConsentExtensionConstants.WEEK, ConsentExtensionConstants.FORTNIGHT,
+ ConsentExtensionConstants.MONTH, ConsentExtensionConstants.HALF_YEAR,
+ ConsentExtensionConstants.YEAR);
+
+ return (periodTypes.contains(periodType));
+ }
+
+ public static boolean validateRevokeStatus(JSONObject revokedNotification) {
+
+ String revokedStatus = (String) revokedNotification.get(ConsentExtensionConstants.REVOKED_STATUS);
+
+ return (ConsentExtensionConstants.REVOKED_STATUS.equals(revokedStatus));
+
+ }
+ /**
+ * Method to handle the Payment GET requests.
+ *
+ * @param consentManageData Object containing request details
+ * @param consent Consent stored at initiation post
+ * @throws ConsentManagementException
+ */
+ private static void handlePaymentInitiationGet(ConsentManageData consentManageData, ConsentResource consent,
+ String paymentType) throws ParseException {
+
+ String type = ConsentExtensionConstants.VRP.equals(paymentType) ? ConsentExtensionConstants.VRP :
+ ConsentExtensionConstants.PAYMENTS;
+ JSONObject receiptJSON = (JSONObject) new JSONParser(JSONParser.MODE_PERMISSIVE).
+ parse(consent.getReceipt());
+ consentManageData.setResponsePayload(ConsentManageUtil
+ .getInitiationRetrievalResponse(receiptJSON, consent, consentManageData, type));
+ consentManageData.setResponseStatus(ResponseStatus.OK);
+ }
+
+
+ /**
+ * Utility class to check whether the Debtor/Creditor AccountSecondary Identification is valid.
+ *
+ * @param accSecondaryIdentification Debtor/Creditor Account Secondary Identification
+ * @return
+ */
+ public static boolean isSecondaryIdentificationValid(String accSecondaryIdentification) {
+ return (accSecondaryIdentification.length() <= 34);
+ }
+
+ /**
+ * Utility class to check whether the Debtor/Creditor Account Name is valid.
+ *
+ * @param accName Debtor/Creditor Account Name
+ * @return
+ */
+ public static boolean isAccNameValid(String accName) {
+ return (accName.length() <= 350);
+ }
+
+
+ /**
+ * Utility class to check whether the Debtor/Creditor Account Identification is valid.
+ *
+ * @param identification Debtor/Creditor Account Identification
+ * @return
+ */
+ public static boolean isIdentificationValid(String identification) {
+ return (identification.length() <= 256);
+ }
+
+
+ /**
+ * Utility class to check whether the Debtor/Creditor Account Scheme name matches with Enum values.
+ *
+ * @param schemeName Debtor/Creditor Account Scheme Name
+ * @return
+ */
+ public static boolean isSchemeNameValid(String schemeName) {
+ EnumSet set = EnumSet.allOf(DebtorAccountSchemeNameEnum.class);
+ return set.contains(DebtorAccountSchemeNameEnum.fromValue(schemeName));
+ }
+
+ /**
+ * Utility class to check whether the Debtor/Creditor Account Scheme name length.
+ *
+ * @param schemeName Debtor/Creditor Account Scheme Name
+ * @return
+ */
+ public static boolean validateSchemeNameLength(String schemeName) {
+ return (schemeName.length() <= 256);
+ }
+
+ /**
+ * Method to validate debtor account in vrp.
+ *
+ * @param debtorAccount Debtor Account object
+ * @return validationResponse
+ */
+ public static JSONObject validateVRPDebtorAccount(JSONObject debtorAccount) {
+
+ JSONObject validationResponse = new JSONObject();
+
+ //Check Debtor Account exists
+ if (debtorAccount.containsKey(ConsentExtensionConstants.SCHEME_NAME)) {
+ //Check Debtor Account Scheme name exists
+ if (StringUtils.isEmpty(debtorAccount.getAsString(ConsentExtensionConstants.SCHEME_NAME))) {
+ log.error(ErrorConstants.MISSING_DEBTOR_ACC_SCHEME_NAME);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS, ErrorConstants.MISSING_DEBTOR_ACC_SCHEME_NAME);
+ return validationResponse;
+ }
+
+ Object schemeName = debtorAccount.get(ConsentExtensionConstants.SCHEME_NAME);
+
+ if (schemeName == null || StringUtils.isEmpty(schemeName.toString())) {
+ log.error(ErrorConstants.MISSING_DEBTOR_ACC_SCHEME_NAME);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS, ErrorConstants.MISSING_DEBTOR_ACC_SCHEME_NAME);
+ return validationResponse;
+ }
+ //Validate Debtor Account Scheme name
+ if (!(schemeName instanceof String) ||
+ ConsentManageUtil.isSchemeNameValid((String) schemeName) ||
+ !ConsentManageUtil.validateSchemeNameLength((String) schemeName)) {
+ log.error(ErrorConstants.INVALID_DEBTOR_ACC_SCHEME_NAME);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS, ErrorConstants.INVALID_DEBTOR_ACC_SCHEME_NAME);
+ return validationResponse;
+ }
+ } else {
+ log.error(ErrorConstants.MISSING_DEBTOR_ACC_SCHEME_NAME);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS, ErrorConstants.INVALID_DEBTOR_ACC_SCHEME_NAME);
+ return validationResponse;
+ }
+
+ //Check Debtor Account Identification existing
+ if (debtorAccount.containsKey(ConsentExtensionConstants.IDENTIFICATION)) {
+ //Check Debtor Account Identification is empty
+ if (StringUtils.isEmpty(debtorAccount.getAsString(ConsentExtensionConstants.IDENTIFICATION))) {
+ log.error(ErrorConstants.MISSING_DEBTOR_ACC_SCHEME_NAME);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS,
+ ErrorConstants.MISSING_DEBTOR_ACC_IDENTIFICATION);
+ return validationResponse;
+ }
+
+ Object identification = debtorAccount.get(ConsentExtensionConstants.IDENTIFICATION);
+ //Validate Debtor Account Identification
+ if (!(identification instanceof String) ||
+ !ConsentManageUtil.isIdentificationValid((String) identification)) {
+ log.error(ErrorConstants.INVALID_DEBTOR_ACC_IDENTIFICATION);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS,
+ ErrorConstants.MISSING_DEBTOR_ACC_IDENTIFICATION);
+ return validationResponse;
+ }
+ } else {
+ log.error(ErrorConstants.MISSING_DEBTOR_ACC_IDENTIFICATION);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS, ErrorConstants.MISSING_DEBTOR_ACC_IDENTIFICATION);
+ return validationResponse;
+ }
+
+ //Validate Debtor Account Name
+
+ Object debtorAcc = debtorAccount.get(ConsentExtensionConstants.NAME);
+
+ if (debtorAcc == null || StringUtils.isEmpty(debtorAcc.toString())) {
+ log.error(ErrorConstants.FIELD_MISSING);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS, ErrorConstants.FIELD_MISSING);
+ return validationResponse;
+ }
+
+ if (debtorAccount.containsKey(ConsentExtensionConstants.NAME) &&
+ (!(debtorAccount.get(ConsentExtensionConstants.NAME) instanceof String) ||
+ !ConsentManageUtil.isAccNameValid(debtorAccount
+ .getAsString(ConsentExtensionConstants.NAME)))) {
+ log.error(ErrorConstants.INVALID_DEBTOR_ACC_NAME);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS, ErrorConstants.INVALID_DEBTOR_ACC_NAME);
+ return validationResponse;
+ }
+
+ //Validate Debtor Account Secondary Identification
+ if (debtorAccount.containsKey(ConsentExtensionConstants.SECONDARY_IDENTIFICATION) &&
+ (!(debtorAccount.get(ConsentExtensionConstants.SECONDARY_IDENTIFICATION) instanceof String) ||
+ !ConsentManageUtil.isSecondaryIdentificationValid(debtorAccount
+ .getAsString(ConsentExtensionConstants.SECONDARY_IDENTIFICATION)))) {
+ log.error(ErrorConstants.INVALID_DEBTOR_ACC_SEC_IDENTIFICATION);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS,
+ ErrorConstants.INVALID_DEBTOR_ACC_SEC_IDENTIFICATION);
+ return validationResponse;
+ }
+
+ //Validate Sort Code number scheme
+ String schemeName = debtorAccount.getAsString(ConsentExtensionConstants.SCHEME_NAME);
+ String identification = debtorAccount.getAsString(ConsentExtensionConstants.IDENTIFICATION);
+ if (!checkSortCodeSchemeNameAndIdentificationValidity(schemeName, identification)) {
+ log.error(ErrorConstants.INVALID_IDENTIFICATION);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS, ErrorConstants.INVALID_IDENTIFICATION);
+ return validationResponse;
+ }
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, true);
+ return validationResponse;
+ }
+
+
+ /**
+ * Validate creditor account in vrp initiation payload.
+ *
+ * @param creditorAccount Creditor Account object
+ *
+ * @return validationResponse
+ */
+ public static JSONObject validateVRPCreditorAccount(JSONObject creditorAccount) {
+
+ JSONObject validationResponse = new JSONObject();
+
+ //Check Creditor Account exists
+ if (creditorAccount.containsKey(ConsentExtensionConstants.SCHEME_NAME)) {
+ //Check Creditor Account Scheme name exists
+ if (StringUtils.isEmpty(creditorAccount.getAsString(ConsentExtensionConstants.SCHEME_NAME))) {
+ log.error(ErrorConstants.MISSING_DEBTOR_ACC_SCHEME_NAME);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS,
+ ErrorConstants.MISSING_CREDITOR_ACC_SCHEME_NAME);
+ return validationResponse;
+ }
+
+ Object schemeName = creditorAccount.get(ConsentExtensionConstants.SCHEME_NAME);
+ //Validate Creditor Account Scheme name
+ if (!(schemeName instanceof String) ||
+ ConsentManageUtil.isSchemeNameValid((String) schemeName) ||
+ !ConsentManageUtil.validateSchemeNameLength((String) schemeName)) {
+ log.error(ErrorConstants.INVALID_CREDITOR_ACC_SCHEME_NAME);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS,
+ ErrorConstants.INVALID_CREDITOR_ACC_SCHEME_NAME);
+ return validationResponse;
+ }
+ } else {
+ log.error(ErrorConstants.MISSING_CREDITOR_ACC_SCHEME_NAME);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS,
+ ErrorConstants.INVALID_CREDITOR_ACC_SCHEME_NAME);
+ return validationResponse;
+ }
+
+ //Check Creditor Account Identification existing
+ if (creditorAccount.containsKey(ConsentExtensionConstants.IDENTIFICATION)) {
+ //Check Creditor Account Identification is empty
+ if (StringUtils.isEmpty(creditorAccount.getAsString(ConsentExtensionConstants.IDENTIFICATION))) {
+ log.error(ErrorConstants.MISSING_CREDITOR_ACC_IDENTIFICATION);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS,
+ ErrorConstants.MISSING_CREDITOR_ACC_IDENTIFICATION);
+ return validationResponse;
+ }
+
+ Object identification = creditorAccount.get(ConsentExtensionConstants.IDENTIFICATION);
+ //Validate Creditor Account Identification
+ if (!(identification instanceof String) ||
+ !ConsentManageUtil.isIdentificationValid((String) identification)) {
+ log.error(ErrorConstants.INVALID_CREDITOR_ACC_IDENTIFICATION);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS,
+ ErrorConstants.MISSING_CREDITOR_ACC_IDENTIFICATION);
+ return validationResponse;
+ }
+ } else {
+ log.error(ErrorConstants.MISSING_CREDITOR_ACC_IDENTIFICATION);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS,
+ ErrorConstants.MISSING_CREDITOR_ACC_IDENTIFICATION);
+ return validationResponse;
+ }
+
+ //Validate Creditor Account Name
+ Object creditorAcc = creditorAccount.get(ConsentExtensionConstants.NAME);
+
+ if (creditorAcc == null || StringUtils.isEmpty(creditorAcc.toString())) {
+ log.error(ErrorConstants.FIELD_MISSING);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS, ErrorConstants.FIELD_MISSING);
+ return validationResponse;
+ }
+ if (creditorAccount.containsKey(ConsentExtensionConstants.NAME) &&
+ (!(creditorAccount.get(ConsentExtensionConstants.NAME) instanceof String) ||
+ !ConsentManageUtil.isAccNameValid(creditorAccount
+ .getAsString(ConsentExtensionConstants.NAME)))) {
+ log.error(ErrorConstants.INVALID_CREDITOR_ACC_NAME);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS, ErrorConstants.INVALID_CREDITOR_ACC_NAME);
+ return validationResponse;
+ }
+
+ //Validate Creditor Account Secondary Identification
+ Object creditorAccSecondaryIdentification = creditorAccount.get(ConsentExtensionConstants
+ .SECONDARY_IDENTIFICATION);
+
+ if (creditorAccSecondaryIdentification == null || StringUtils.isEmpty
+ (creditorAccSecondaryIdentification.toString())) {
+ log.error(ErrorConstants.FIELD_MISSING);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS, ErrorConstants.FIELD_MISSING);
+ return validationResponse;
+ }
+ if (creditorAccount.containsKey(ConsentExtensionConstants.SECONDARY_IDENTIFICATION) &&
+ (!(creditorAccount.get(ConsentExtensionConstants.SECONDARY_IDENTIFICATION) instanceof String) ||
+ !ConsentManageUtil.isSecondaryIdentificationValid(creditorAccount
+ .getAsString(ConsentExtensionConstants.SECONDARY_IDENTIFICATION)))) {
+ log.error(ErrorConstants.INVALID_CREDITOR_ACC_IDENTIFICATION);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS,
+ ErrorConstants.INVALID_CREDITOR_ACC_SEC_IDENTIFICATION);
+ return validationResponse;
+ }
+
+ //Validate Sort Code number scheme
+ String schemeName = creditorAccount.getAsString(ConsentExtensionConstants.SCHEME_NAME);
+ String identification = creditorAccount.getAsString(ConsentExtensionConstants.IDENTIFICATION);
+ if (!checkSortCodeSchemeNameAndIdentificationValidity(schemeName, identification)) {
+ log.error(ErrorConstants.INVALID_IDENTIFICATION);
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+ validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
+ validationResponse.put(ConsentExtensionConstants.ERRORS, ErrorConstants.INVALID_IDENTIFICATION);
+ return validationResponse;
+ }
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, true);
+ return validationResponse;
+ }
}
+
+
From beb78faffc1d4f1da73b9fccfecef821a3b2c0d6 Mon Sep 17 00:00:00 2001
From: kalpana
Date: Sun, 26 Nov 2023 18:40:24 +0530
Subject: [PATCH 022/281] VRP consent initiation flow implementation
---
.../common/util/ErrorConstants.java | 27 +++-
.../common/ConsentExtensionConstants.java | 4 +-
.../manage/impl/VRPConsentRequestHandler.java | 36 +++--
.../validator/VRPConsentRequestValidator.java | 82 +++++------
.../extensions/util/ConsentManageUtil.java | 138 +++---------------
5 files changed, 102 insertions(+), 185 deletions(-)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java
index 182b4c35..78a9f1a7 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java
@@ -108,6 +108,7 @@ public class ErrorConstants {
public static final String PATH_CONSENT_ID = "Data.Initiation.Consent-id";
public static final String PATH_DATA = "Data";
public static final String PATH_INITIATION = "Data.Initiation";
+ public static final String PATH_RISK = "Data.Risk";
public static final String PATH_URL = "Data.Url";
public static final String PATH_EXPIRATION_DATE = "Data.Expiration-Date";
public static final String MSG_MISSING_DEBTOR_ACC = "Mandatory parameter DebtorAccount is missing in the payload.";
@@ -206,6 +207,11 @@ public class ErrorConstants {
ErrorConstants.PATH_DATA;
public static final String INITIATION_NOT_FOUND = "Initiation is not found or empty in the request.:" +
ErrorConstants.PATH_INITIATION;
+
+ public static final String RISK_MISMATCH = "RISK Does Not Match.:" + ErrorConstants.PATH_RISK;
+ public static final String RISK_NOT_FOUND = "RISK is not found or empty in the request.:" +
+ ErrorConstants.PATH_RISK;
+
public static final String INVALID_URI_ERROR = "Path requested is invalid. :" + ErrorConstants.PATH_URL;
public static final String COF_CONSENT_STATE_INVALID = "Confirmation of Funds validation failed due to invalid" +
" consent state.:" + ErrorConstants.PATH_STATUS;
@@ -219,13 +225,24 @@ public class ErrorConstants {
public static final String CONSENT_ID_NOT_FOUND = "Consent ID not available in consent data";
public static final String FIELD_INVALID_DATE = "OB.Field.InvalidDate";
public static final String EXPIRED_DATE_ERROR = "The ExpirationDateTime value has to be a future date.";
- public static final String PATH_MAXIMUM_INDIVIDUAL_AMOUNT = "Data.ControlParameters.MaximumIndividualAmount.Amount";
- public static final String INVALID_MAXIMUM_INDIVIDUAL_AMOUNT = "Invalid value for Amount in MaximumIndividualAmount";
- public static final String INVALID_CURRENCY = "Invalid value for currency in MaximumIndividualAmount" ;
+ // vrp
+ public static final String MAXIMUM_INDIVIDUAL_AMOUNT_NOT_FOUND = "Mandatory parameter MaximumIndividualAmount" +
+ " Amount is missing in the payload.";
+ public static final String PATH_MAXIMUM_INDIVIDUAL_CURRENCY = "Data.ControlParameters." +
+ "MaximumIndividualAmount.Currency";
+ public static final String MAXIMUM_INDIVIDUAL_AMOUNT_CURRENCY_NOT_FOUND = "Mandatory parameter " +
+ "MaximumIndividualAmount Currency is missing in the payload";
+ public static final String INVALID_MAXIMUM_INDIVIDUAL_AMOUNT = "Invalid value for Amount " +
+ "in MaximumIndividualAmount";
+ public static final String INVALID_CURRENCY = "Mandatory parameter " +
+ "MaximumIndividualAmount Currency is missing in the payload";
public static final String INVALID_PERIOD_ALIGNMENT = "Invalid value for period alignment in PeriodicLimits";
- public static final String INVALID_PERIOD_TYPE = "Invalid value for period type in PeriodicLimits";
- public static final String PATH_PERIOD_TYPE = "Data.ControlParameters.PeriodicLimits.PeriodType";
+ public static final String INVALID_PERIOD_TYPE = "Mandatory parameter " +
+ "period type is missing in the payload";
public static final String INVALID_VALID_TO_DATE = "Valid to Date specified in the request is invalid";
public static final String PATH_VALID_TO_DATE = "Data.ControlParameters.ValidToDateTime";
+ public static final String PATH_MAXIMUM_INDIVIDUAL_AMOUNT = "Data.ControlParameters.MaximumIndividualAmount.Amount";
+ public static final String PATH_PERIOD_TYPE = "Data.ControlParameters.PeriodicLimits.PeriodType";
+ public static final String PATH_PERIOD_ALIGNMENT = "Data.ControlParameters.PeriodLimits.PeriodAlignment";
}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/ConsentExtensionConstants.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/ConsentExtensionConstants.java
index f18db57b..ae8944ab 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/ConsentExtensionConstants.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/ConsentExtensionConstants.java
@@ -122,8 +122,8 @@ public class ConsentExtensionConstants {
public static final String INSTRUCTION_IDENTIFICATION = "InstructionIdentification";
public static final String REJECTED_STATUS = "rejected";
public static final String OPEN_ENDED_AUTHORIZATION = "Open Ended Authorization Requested";
- public static final String DEBTOR_ACC_TITLE = "DebtorAccount";
- public static final String SCHEME_NAME_TITLE = "SchemeName";
+ public static final String DEBTOR_ACC_TITLE = "Debtor Account";
+ public static final String SCHEME_NAME_TITLE = "Scheme Name";
public static final String IDENTIFICATION_TITLE = "Identification";
public static final String NAME_TITLE = "Name";
public static final String SECONDARY_IDENTIFICATION_TITLE = "Secondary Identification";
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/impl/VRPConsentRequestHandler.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/impl/VRPConsentRequestHandler.java
index 45ac82aa..91d9677e 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/impl/VRPConsentRequestHandler.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/impl/VRPConsentRequestHandler.java
@@ -1,9 +1,19 @@
/**
- * Copyright (c) 2021-2022, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
- * This software is the property of WSO2 LLC. and its suppliers, if any.
- * Dissemination of any information or reproduction of any material contained
- * herein in any form is strictly forbidden, unless permitted by WSO2 expressly.
- * You may not alter or remove any copyright or other notice from copies of this content.
+ * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package com.wso2.openbanking.accelerator.consent.extensions.manage.impl;
@@ -12,7 +22,6 @@
import com.wso2.openbanking.accelerator.common.util.ErrorConstants;
import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentException;
import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentExtensionConstants;
-import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentExtensionUtils;
import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentServiceUtil;
import com.wso2.openbanking.accelerator.consent.extensions.common.ResponseStatus;
import com.wso2.openbanking.accelerator.consent.extensions.internal.ConsentExtensionsDataHolder;
@@ -51,12 +60,6 @@ public class VRPConsentRequestHandler implements ConsentManageRequestHandler {
public void handleConsentManagePost(ConsentManageData consentManageData) {
try {
- //Validate cutoff datetime
- if (ConsentExtensionUtils.shouldInitiationRequestBeRejected()) {
- log.error(ErrorConstants.MSG_ELAPSED_CUT_OFF_DATE_TIME);
- throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.PAYMENT_INITIATION_HANDLE_ERROR);
- }
-
//Get the request payload from the ConsentManageData
Object request = consentManageData.getPayload();
if (!(request instanceof JSONObject)) {
@@ -79,11 +82,11 @@ public void handleConsentManagePost(ConsentManageData consentManageData) {
handlePaymentPost(consentManageData, requestObject, response);
} catch (ConsentManagementException e) {
- log.error(e.getMessage());
+ log.error("Error occurred while handling the initiation request", e);
throw new ConsentException(ResponseStatus.INTERNAL_SERVER_ERROR,
ErrorConstants.PAYMENT_INITIATION_HANDLE_ERROR);
}
- }
+ }
@Override
@@ -176,11 +179,12 @@ private void handlePaymentPost(ConsentManageData consentManageData, JSONObject r
consentAttributes.put(ConsentExtensionConstants.PERIOD_TYPE, ((JSONObject) ((JSONArray) (controlParameters)
.get(ConsentExtensionConstants.PERIODIC_LIMITS)).get(0)).get(ConsentExtensionConstants.PERIOD_TYPE)
.toString());
+ consentAttributes.put(ConsentExtensionConstants.PERIOD_ALIGNMENT, ((JSONObject) ((JSONArray) (controlParameters)
+ .get(ConsentExtensionConstants.PERIODIC_LIMITS)).get(0)).get(ConsentExtensionConstants.PERIOD_TYPE)
+ .toString());
consentAttributes.put(ConsentExtensionConstants.PERIOD_AMOUNT_LIMIT, ((JSONObject)
((JSONArray) (controlParameters).get(ConsentExtensionConstants.PERIODIC_LIMITS)).get(0))
.get(ConsentExtensionConstants.PERIOD_AMOUNT_LIMIT).toString());
- consentAttributes.put(ConsentExtensionConstants.PAID_AMOUNT, "0");
- consentAttributes.put(ConsentExtensionConstants.LAST_PAYMENT_DATE, "0");
Map headers = consentManageData.getHeaders();
//Setting response headers
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/validator/VRPConsentRequestValidator.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/validator/VRPConsentRequestValidator.java
index 0bb6bae1..c07c183e 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/validator/VRPConsentRequestValidator.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/validator/VRPConsentRequestValidator.java
@@ -1,13 +1,19 @@
/**
- * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.com). All Rights Reserved.
+ * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
*
- * This software is the property of WSO2 Inc. and its suppliers, if any.
- * Dissemination of any information or reproduction of any material contained
- * herein is strictly forbidden, unless permitted by WSO2 in accordance with
- * the WSO2 Software License available at https://wso2.com/licenses/eula/3.1.
- * For specific language governing the permissions and limitations under this
- * license, please see the license as well as any agreement you’ve entered into
- * with WSO2 governing the purchase of this software and any associated services.
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package com.wso2.openbanking.accelerator.consent.extensions.manage.validator;
@@ -31,19 +37,6 @@
public class VRPConsentRequestValidator {
private static final Log log = LogFactory.getLog(VRPConsentRequestValidator.class);
-
- public static final String MAXIMUM_INDIVIDUAL_AMOUNT_NOT_FOUND = "Instructed Amount isn't present in the payload";
-
- public static final String PATH_MAXIMUM_INDIVIDUAL_CURRENCY = "Data.ControlParameters." +
- "MaximumIndividualAmount.Currency";
-
- public static final String MAXIMUM_INDIVIDUAL_AMOUNT_CURRENCY_NOT_FOUND = "Instructed currency isn't " +
- "present in the payload";
-
- public static final String INVALID_PERIOD_ALIGNMENT = "Invalid value for period alignment in PeriodicLimits";
-
- public static final String PATH_PERIOD_ALIGNMENT = "Data.ControlParameters.PeriodLimits.PeriodAlignment";
-
/**
* Method to validate variable recurring payment control parameters.
*
@@ -57,27 +50,28 @@ public static JSONObject validatecontrolParameters(JSONObject controlParameters)
if (controlParameters.containsKey(ConsentExtensionConstants.MAXIMUM_INDIVIDUAL_AMOUNT)) {
JSONObject maximumIndividualAmount = (JSONObject) controlParameters
.get(ConsentExtensionConstants.MAXIMUM_INDIVIDUAL_AMOUNT);
- Object amount = maximumIndividualAmount.get(ConsentExtensionConstants.AMOUNT);
- Object currency = maximumIndividualAmount.get(ConsentExtensionConstants.CURRENCY);
+ String amount = maximumIndividualAmount.getAsString(ConsentExtensionConstants.AMOUNT);
+ String currency = maximumIndividualAmount.getAsString(ConsentExtensionConstants.CURRENCY);
// validate amount
- if (!ConsentManageUtil.validateAmount(maximumIndividualAmount)) {
+ if (!ConsentManageUtil.validateMaximumIndividualAmount(maximumIndividualAmount)) {
log.error(ErrorConstants.INVALID_MAXIMUM_INDIVIDUAL_AMOUNT);
return ConsentManageUtil.getValidationResponse(ErrorConstants.FIELD_INVALID,
ErrorConstants.INVALID_MAXIMUM_INDIVIDUAL_AMOUNT,
ErrorConstants.PATH_MAXIMUM_INDIVIDUAL_AMOUNT);
}
- if (amount == null || StringUtils.isEmpty(amount.toString())) {
- log.error(MAXIMUM_INDIVIDUAL_AMOUNT_NOT_FOUND);
+ if (StringUtils.isEmpty(amount)) {
+ log.error(ErrorConstants.MAXIMUM_INDIVIDUAL_AMOUNT_NOT_FOUND);
validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
- validationResponse.put(ConsentExtensionConstants.ERRORS, MAXIMUM_INDIVIDUAL_AMOUNT_NOT_FOUND);
+ validationResponse.put(ConsentExtensionConstants.ERRORS,
+ ErrorConstants.MAXIMUM_INDIVIDUAL_AMOUNT_NOT_FOUND);
return validationResponse;
}
//validate currency
- if (!ConsentManageUtil.validateCurrency(maximumIndividualAmount)) {
+ if (!ConsentManageUtil.validateMaximumIndividualAmountCurrency(maximumIndividualAmount)) {
log.error(ErrorConstants.INVALID_CURRENCY);
validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
@@ -87,12 +81,12 @@ public static JSONObject validatecontrolParameters(JSONObject controlParameters)
ErrorConstants.INVALID_CURRENCY, ErrorConstants.PATH_MAXIMUM_INDIVIDUAL_AMOUNT);
}
- if (currency == null || StringUtils.isEmpty(currency.toString())) {
- log.error(MAXIMUM_INDIVIDUAL_AMOUNT_CURRENCY_NOT_FOUND);
+ if (StringUtils.isEmpty(currency)) {
+ log.error(ErrorConstants.MAXIMUM_INDIVIDUAL_AMOUNT_CURRENCY_NOT_FOUND);
validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
validationResponse.put(ConsentExtensionConstants.ERRORS,
- MAXIMUM_INDIVIDUAL_AMOUNT_CURRENCY_NOT_FOUND);
+ ErrorConstants.MAXIMUM_INDIVIDUAL_AMOUNT_CURRENCY_NOT_FOUND);
return validationResponse;
}
}
@@ -123,40 +117,40 @@ public static JSONObject validatecontrolParameters(JSONObject controlParameters)
while (it.hasNext()) {
JSONObject limit = (JSONObject) it.next();
- Object amount = limit.get(ConsentExtensionConstants.AMOUNT);
- Object currency = limit.get(ConsentExtensionConstants.CURRENCY);
- Object periodType = limit.get(ConsentExtensionConstants.PERIOD_TYPE);
+ String amount = limit.getAsString(ConsentExtensionConstants.AMOUNT);
+ String currency = limit.getAsString(ConsentExtensionConstants.CURRENCY);
+ String periodType = limit.getAsString(ConsentExtensionConstants.PERIOD_TYPE);
// validate amount
- if (!ConsentManageUtil.validateAmount(limit)) {
+ if (!ConsentManageUtil.validateMaximumIndividualAmount(limit)) {
log.error(ErrorConstants.INVALID_MAXIMUM_INDIVIDUAL_AMOUNT);
return ConsentManageUtil.getValidationResponse(ErrorConstants.FIELD_INVALID,
ErrorConstants.INVALID_MAXIMUM_INDIVIDUAL_AMOUNT,
ErrorConstants.PATH_MAXIMUM_INDIVIDUAL_AMOUNT);
}
- if (amount == null || StringUtils.isEmpty(amount.toString())) {
- log.error(MAXIMUM_INDIVIDUAL_AMOUNT_NOT_FOUND);
+ if (StringUtils.isEmpty(amount)) {
+ log.error(ErrorConstants.MAXIMUM_INDIVIDUAL_AMOUNT_NOT_FOUND);
validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
validationResponse.put(ConsentExtensionConstants.ERRORS,
- MAXIMUM_INDIVIDUAL_AMOUNT_NOT_FOUND);
+ ErrorConstants.MAXIMUM_INDIVIDUAL_AMOUNT_NOT_FOUND);
return validationResponse;
}
//validate currency
- if (!ConsentManageUtil.validateCurrency(limit)) {
+ if (!ConsentManageUtil.validateMaximumIndividualAmountCurrency(limit)) {
log.error(ErrorConstants.INVALID_CURRENCY);
return ConsentManageUtil.getValidationResponse(ErrorConstants.FIELD_INVALID,
ErrorConstants.INVALID_CURRENCY, ErrorConstants.PATH_MAXIMUM_INDIVIDUAL_AMOUNT);
}
- if (currency == null || StringUtils.isEmpty(currency.toString())) {
- log.error(MAXIMUM_INDIVIDUAL_AMOUNT_CURRENCY_NOT_FOUND);
+ if (StringUtils.isEmpty(currency)) {
+ log.error(ErrorConstants.MAXIMUM_INDIVIDUAL_AMOUNT_CURRENCY_NOT_FOUND);
validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
validationResponse.put(ConsentExtensionConstants.ERRORS,
- MAXIMUM_INDIVIDUAL_AMOUNT_CURRENCY_NOT_FOUND);
+ ErrorConstants.MAXIMUM_INDIVIDUAL_AMOUNT_CURRENCY_NOT_FOUND);
return validationResponse;
}
@@ -164,7 +158,7 @@ public static JSONObject validatecontrolParameters(JSONObject controlParameters)
if (ConsentManageUtil.validatePeriodicAlignment(limit)) {
log.error(ErrorConstants.INVALID_PERIOD_ALIGNMENT);
return ConsentManageUtil.getValidationResponse(ErrorConstants.FIELD_INVALID,
- INVALID_PERIOD_ALIGNMENT, PATH_PERIOD_ALIGNMENT);
+ ErrorConstants.INVALID_PERIOD_ALIGNMENT, ErrorConstants.PATH_PERIOD_ALIGNMENT);
}
//validate period type
@@ -174,7 +168,7 @@ public static JSONObject validatecontrolParameters(JSONObject controlParameters)
ErrorConstants.INVALID_PERIOD_TYPE, ErrorConstants.PATH_PERIOD_TYPE);
}
- if (periodType == null || StringUtils.isEmpty(periodType.toString())) {
+ if (StringUtils.isEmpty(periodType)) {
log.error(ErrorConstants.INVALID_PERIOD_TYPE);
validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/util/ConsentManageUtil.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/util/ConsentManageUtil.java
index 717e0af9..c623ed94 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/util/ConsentManageUtil.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/util/ConsentManageUtil.java
@@ -30,8 +30,6 @@
import com.wso2.openbanking.accelerator.consent.mgt.dao.models.ConsentResource;
import com.wso2.openbanking.accelerator.consent.mgt.dao.models.DetailedConsentResource;
import net.minidev.json.JSONObject;
-import net.minidev.json.parser.JSONParser;
-import net.minidev.json.parser.ParseException;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -628,22 +626,28 @@ public static boolean isConsentExpirationTimeValid(String expDateVal) {
/**
* validate the maximum amount in the payload in VRP.
+ * @param maximumIndividualAmount Maximum Individual Amount
+ * @return
*/
- public static boolean validateAmount(JSONObject maximumIndividualAmount) {
+ public static boolean validateMaximumIndividualAmount(JSONObject maximumIndividualAmount) {
return (maximumIndividualAmount != null && maximumIndividualAmount
.containsKey(ConsentExtensionConstants.AMOUNT));
}
/**
* validate the currency in the payload in VRP.
+ * @param maximumIndividualAmount Maximum Individual Amount
+ * @return
*/
- public static boolean validateCurrency(JSONObject maximumIndividualAmount) {
+ public static boolean validateMaximumIndividualAmountCurrency(JSONObject maximumIndividualAmount) {
return (maximumIndividualAmount != null && maximumIndividualAmount
.containsKey(ConsentExtensionConstants.CURRENCY));
}
/**
* validate the periodiclimits in the payload in VRP.
+ * @param periodiclimit
+ * @return
*/
public static boolean validatePeriodicAlignment(JSONObject periodiclimit) {
String periodAlignment = (String) periodiclimit.get(ConsentExtensionConstants.PERIOD_ALIGNMENT);
@@ -654,6 +658,8 @@ public static boolean validatePeriodicAlignment(JSONObject periodiclimit) {
/**
* method to validate periodic type in VRP.
+ * @param periodiclimit Maximum Individual Amount
+ * @return
*/
public static boolean validatePeriodicType(JSONObject periodiclimit) {
String periodType = (String) periodiclimit.get(ConsentExtensionConstants.PERIOD_TYPE);
@@ -666,86 +672,6 @@ public static boolean validatePeriodicType(JSONObject periodiclimit) {
return (periodTypes.contains(periodType));
}
- public static boolean validateRevokeStatus(JSONObject revokedNotification) {
-
- String revokedStatus = (String) revokedNotification.get(ConsentExtensionConstants.REVOKED_STATUS);
-
- return (ConsentExtensionConstants.REVOKED_STATUS.equals(revokedStatus));
-
- }
- /**
- * Method to handle the Payment GET requests.
- *
- * @param consentManageData Object containing request details
- * @param consent Consent stored at initiation post
- * @throws ConsentManagementException
- */
- private static void handlePaymentInitiationGet(ConsentManageData consentManageData, ConsentResource consent,
- String paymentType) throws ParseException {
-
- String type = ConsentExtensionConstants.VRP.equals(paymentType) ? ConsentExtensionConstants.VRP :
- ConsentExtensionConstants.PAYMENTS;
- JSONObject receiptJSON = (JSONObject) new JSONParser(JSONParser.MODE_PERMISSIVE).
- parse(consent.getReceipt());
- consentManageData.setResponsePayload(ConsentManageUtil
- .getInitiationRetrievalResponse(receiptJSON, consent, consentManageData, type));
- consentManageData.setResponseStatus(ResponseStatus.OK);
- }
-
-
- /**
- * Utility class to check whether the Debtor/Creditor AccountSecondary Identification is valid.
- *
- * @param accSecondaryIdentification Debtor/Creditor Account Secondary Identification
- * @return
- */
- public static boolean isSecondaryIdentificationValid(String accSecondaryIdentification) {
- return (accSecondaryIdentification.length() <= 34);
- }
-
- /**
- * Utility class to check whether the Debtor/Creditor Account Name is valid.
- *
- * @param accName Debtor/Creditor Account Name
- * @return
- */
- public static boolean isAccNameValid(String accName) {
- return (accName.length() <= 350);
- }
-
-
- /**
- * Utility class to check whether the Debtor/Creditor Account Identification is valid.
- *
- * @param identification Debtor/Creditor Account Identification
- * @return
- */
- public static boolean isIdentificationValid(String identification) {
- return (identification.length() <= 256);
- }
-
-
- /**
- * Utility class to check whether the Debtor/Creditor Account Scheme name matches with Enum values.
- *
- * @param schemeName Debtor/Creditor Account Scheme Name
- * @return
- */
- public static boolean isSchemeNameValid(String schemeName) {
- EnumSet set = EnumSet.allOf(DebtorAccountSchemeNameEnum.class);
- return set.contains(DebtorAccountSchemeNameEnum.fromValue(schemeName));
- }
-
- /**
- * Utility class to check whether the Debtor/Creditor Account Scheme name length.
- *
- * @param schemeName Debtor/Creditor Account Scheme Name
- * @return
- */
- public static boolean validateSchemeNameLength(String schemeName) {
- return (schemeName.length() <= 256);
- }
-
/**
* Method to validate debtor account in vrp.
*
@@ -769,7 +695,7 @@ public static JSONObject validateVRPDebtorAccount(JSONObject debtorAccount) {
Object schemeName = debtorAccount.get(ConsentExtensionConstants.SCHEME_NAME);
- if (schemeName == null || StringUtils.isEmpty(schemeName.toString())) {
+ if (StringUtils.isEmpty(schemeName.toString())) {
log.error(ErrorConstants.MISSING_DEBTOR_ACC_SCHEME_NAME);
validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
@@ -778,8 +704,8 @@ public static JSONObject validateVRPDebtorAccount(JSONObject debtorAccount) {
}
//Validate Debtor Account Scheme name
if (!(schemeName instanceof String) ||
- ConsentManageUtil.isSchemeNameValid((String) schemeName) ||
- !ConsentManageUtil.validateSchemeNameLength((String) schemeName)) {
+ ConsentManageUtil.isDebtorAccSchemeNameValid((String) schemeName) ||
+ !ConsentManageUtil.validateDebtorAccSchemeNameLength((String) schemeName)) {
log.error(ErrorConstants.INVALID_DEBTOR_ACC_SCHEME_NAME);
validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
@@ -809,7 +735,7 @@ public static JSONObject validateVRPDebtorAccount(JSONObject debtorAccount) {
Object identification = debtorAccount.get(ConsentExtensionConstants.IDENTIFICATION);
//Validate Debtor Account Identification
if (!(identification instanceof String) ||
- !ConsentManageUtil.isIdentificationValid((String) identification)) {
+ !ConsentManageUtil.isDebtorAccIdentificationValid((String) identification)) {
log.error(ErrorConstants.INVALID_DEBTOR_ACC_IDENTIFICATION);
validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
@@ -839,7 +765,7 @@ public static JSONObject validateVRPDebtorAccount(JSONObject debtorAccount) {
if (debtorAccount.containsKey(ConsentExtensionConstants.NAME) &&
(!(debtorAccount.get(ConsentExtensionConstants.NAME) instanceof String) ||
- !ConsentManageUtil.isAccNameValid(debtorAccount
+ !ConsentManageUtil.isDebtorAccNameValid(debtorAccount
.getAsString(ConsentExtensionConstants.NAME)))) {
log.error(ErrorConstants.INVALID_DEBTOR_ACC_NAME);
validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
@@ -847,30 +773,6 @@ public static JSONObject validateVRPDebtorAccount(JSONObject debtorAccount) {
validationResponse.put(ConsentExtensionConstants.ERRORS, ErrorConstants.INVALID_DEBTOR_ACC_NAME);
return validationResponse;
}
-
- //Validate Debtor Account Secondary Identification
- if (debtorAccount.containsKey(ConsentExtensionConstants.SECONDARY_IDENTIFICATION) &&
- (!(debtorAccount.get(ConsentExtensionConstants.SECONDARY_IDENTIFICATION) instanceof String) ||
- !ConsentManageUtil.isSecondaryIdentificationValid(debtorAccount
- .getAsString(ConsentExtensionConstants.SECONDARY_IDENTIFICATION)))) {
- log.error(ErrorConstants.INVALID_DEBTOR_ACC_SEC_IDENTIFICATION);
- validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
- validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
- validationResponse.put(ConsentExtensionConstants.ERRORS,
- ErrorConstants.INVALID_DEBTOR_ACC_SEC_IDENTIFICATION);
- return validationResponse;
- }
-
- //Validate Sort Code number scheme
- String schemeName = debtorAccount.getAsString(ConsentExtensionConstants.SCHEME_NAME);
- String identification = debtorAccount.getAsString(ConsentExtensionConstants.IDENTIFICATION);
- if (!checkSortCodeSchemeNameAndIdentificationValidity(schemeName, identification)) {
- log.error(ErrorConstants.INVALID_IDENTIFICATION);
- validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
- validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
- validationResponse.put(ConsentExtensionConstants.ERRORS, ErrorConstants.INVALID_IDENTIFICATION);
- return validationResponse;
- }
validationResponse.put(ConsentExtensionConstants.IS_VALID, true);
return validationResponse;
}
@@ -902,8 +804,8 @@ public static JSONObject validateVRPCreditorAccount(JSONObject creditorAccount)
Object schemeName = creditorAccount.get(ConsentExtensionConstants.SCHEME_NAME);
//Validate Creditor Account Scheme name
if (!(schemeName instanceof String) ||
- ConsentManageUtil.isSchemeNameValid((String) schemeName) ||
- !ConsentManageUtil.validateSchemeNameLength((String) schemeName)) {
+ ConsentManageUtil.isDebtorAccSchemeNameValid((String) schemeName) ||
+ !ConsentManageUtil.validateDebtorAccSchemeNameLength((String) schemeName)) {
log.error(ErrorConstants.INVALID_CREDITOR_ACC_SCHEME_NAME);
validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
@@ -935,7 +837,7 @@ public static JSONObject validateVRPCreditorAccount(JSONObject creditorAccount)
Object identification = creditorAccount.get(ConsentExtensionConstants.IDENTIFICATION);
//Validate Creditor Account Identification
if (!(identification instanceof String) ||
- !ConsentManageUtil.isIdentificationValid((String) identification)) {
+ !ConsentManageUtil.isDebtorAccIdentificationValid((String) identification)) {
log.error(ErrorConstants.INVALID_CREDITOR_ACC_IDENTIFICATION);
validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
@@ -964,7 +866,7 @@ public static JSONObject validateVRPCreditorAccount(JSONObject creditorAccount)
}
if (creditorAccount.containsKey(ConsentExtensionConstants.NAME) &&
(!(creditorAccount.get(ConsentExtensionConstants.NAME) instanceof String) ||
- !ConsentManageUtil.isAccNameValid(creditorAccount
+ !ConsentManageUtil.isDebtorAccNameValid(creditorAccount
.getAsString(ConsentExtensionConstants.NAME)))) {
log.error(ErrorConstants.INVALID_CREDITOR_ACC_NAME);
validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
@@ -987,7 +889,7 @@ public static JSONObject validateVRPCreditorAccount(JSONObject creditorAccount)
}
if (creditorAccount.containsKey(ConsentExtensionConstants.SECONDARY_IDENTIFICATION) &&
(!(creditorAccount.get(ConsentExtensionConstants.SECONDARY_IDENTIFICATION) instanceof String) ||
- !ConsentManageUtil.isSecondaryIdentificationValid(creditorAccount
+ !ConsentManageUtil.isDebtorAccSecondaryIdentificationValid(creditorAccount
.getAsString(ConsentExtensionConstants.SECONDARY_IDENTIFICATION)))) {
log.error(ErrorConstants.INVALID_CREDITOR_ACC_IDENTIFICATION);
validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
From 2c5e3a65b69447c87bed5d1f4d12b89c931613b9 Mon Sep 17 00:00:00 2001
From: kalpana
Date: Tue, 28 Nov 2023 09:40:04 +0530
Subject: [PATCH 023/281] VRP consent initiation flow implementation
---
.../AcceleratorConsentExtensionFactory.java | 1 -
.../validator/VRPConsentRequestValidator.java | 1 -
.../extensions/util/ConsentManageUtil.java | 26 +++++++++----------
3 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/factory/AcceleratorConsentExtensionFactory.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/factory/AcceleratorConsentExtensionFactory.java
index 0c2197bd..47a00f48 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/factory/AcceleratorConsentExtensionFactory.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/factory/AcceleratorConsentExtensionFactory.java
@@ -57,7 +57,6 @@ public static ConsentManageRequestHandler getConsentManageRequestValidator(Strin
consentManageRequestHandler = new PaymentConsentRequestHandler();
break;
case ConsentExtensionConstants.VRP_CONSENT_PATH:
- case ConsentExtensionConstants.VRP_RESPONSE_PROCESS_PATH:
consentManageRequestHandler = new VRPConsentRequestHandler();
break;
default:
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/validator/VRPConsentRequestValidator.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/validator/VRPConsentRequestValidator.java
index c07c183e..cd4325b1 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/validator/VRPConsentRequestValidator.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/validator/VRPConsentRequestValidator.java
@@ -270,7 +270,6 @@ public static JSONObject validateVRPInitiationPayload(JSONObject initiation) {
validationResponse.put(ConsentExtensionConstants.IS_VALID, true);
return validationResponse;
}
-
}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/util/ConsentManageUtil.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/util/ConsentManageUtil.java
index c623ed94..9335ae9b 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/util/ConsentManageUtil.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/util/ConsentManageUtil.java
@@ -693,9 +693,9 @@ public static JSONObject validateVRPDebtorAccount(JSONObject debtorAccount) {
return validationResponse;
}
- Object schemeName = debtorAccount.get(ConsentExtensionConstants.SCHEME_NAME);
+ String schemeName = debtorAccount.getAsString(ConsentExtensionConstants.SCHEME_NAME);
- if (StringUtils.isEmpty(schemeName.toString())) {
+ if (StringUtils.isEmpty(schemeName)) {
log.error(ErrorConstants.MISSING_DEBTOR_ACC_SCHEME_NAME);
validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
@@ -704,8 +704,8 @@ public static JSONObject validateVRPDebtorAccount(JSONObject debtorAccount) {
}
//Validate Debtor Account Scheme name
if (!(schemeName instanceof String) ||
- ConsentManageUtil.isDebtorAccSchemeNameValid((String) schemeName) ||
- !ConsentManageUtil.validateDebtorAccSchemeNameLength((String) schemeName)) {
+ ConsentManageUtil.isDebtorAccSchemeNameValid(schemeName) ||
+ !ConsentManageUtil.validateDebtorAccSchemeNameLength(schemeName)) {
log.error(ErrorConstants.INVALID_DEBTOR_ACC_SCHEME_NAME);
validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
@@ -753,9 +753,9 @@ public static JSONObject validateVRPDebtorAccount(JSONObject debtorAccount) {
//Validate Debtor Account Name
- Object debtorAcc = debtorAccount.get(ConsentExtensionConstants.NAME);
+ String debtorAcc = debtorAccount.getAsString(ConsentExtensionConstants.NAME);
- if (debtorAcc == null || StringUtils.isEmpty(debtorAcc.toString())) {
+ if (debtorAcc == null || StringUtils.isEmpty(debtorAcc)) {
log.error(ErrorConstants.FIELD_MISSING);
validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
@@ -801,11 +801,11 @@ public static JSONObject validateVRPCreditorAccount(JSONObject creditorAccount)
return validationResponse;
}
- Object schemeName = creditorAccount.get(ConsentExtensionConstants.SCHEME_NAME);
+ String schemeName = creditorAccount.getAsString(ConsentExtensionConstants.SCHEME_NAME);
//Validate Creditor Account Scheme name
if (!(schemeName instanceof String) ||
- ConsentManageUtil.isDebtorAccSchemeNameValid((String) schemeName) ||
- !ConsentManageUtil.validateDebtorAccSchemeNameLength((String) schemeName)) {
+ ConsentManageUtil.isDebtorAccSchemeNameValid(schemeName) ||
+ !ConsentManageUtil.validateDebtorAccSchemeNameLength(schemeName)) {
log.error(ErrorConstants.INVALID_CREDITOR_ACC_SCHEME_NAME);
validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
@@ -855,9 +855,9 @@ public static JSONObject validateVRPCreditorAccount(JSONObject creditorAccount)
}
//Validate Creditor Account Name
- Object creditorAcc = creditorAccount.get(ConsentExtensionConstants.NAME);
+ String creditorAcc = creditorAccount.getAsString(ConsentExtensionConstants.NAME);
- if (creditorAcc == null || StringUtils.isEmpty(creditorAcc.toString())) {
+ if (creditorAcc == null || StringUtils.isEmpty(creditorAcc)) {
log.error(ErrorConstants.FIELD_MISSING);
validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
@@ -876,11 +876,11 @@ public static JSONObject validateVRPCreditorAccount(JSONObject creditorAccount)
}
//Validate Creditor Account Secondary Identification
- Object creditorAccSecondaryIdentification = creditorAccount.get(ConsentExtensionConstants
+ String creditorAccSecondaryIdentification = creditorAccount.getAsString(ConsentExtensionConstants
.SECONDARY_IDENTIFICATION);
if (creditorAccSecondaryIdentification == null || StringUtils.isEmpty
- (creditorAccSecondaryIdentification.toString())) {
+ (creditorAccSecondaryIdentification)) {
log.error(ErrorConstants.FIELD_MISSING);
validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
From 0c1f9f2bb6e736b57e3b597f10cf78a347fa74bf Mon Sep 17 00:00:00 2001
From: kalpana
Date: Tue, 28 Nov 2023 10:44:50 +0530
Subject: [PATCH 024/281] VRP consent initiation flow implementation
---
.../manage/validator/VRPConsentRequestValidator.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/validator/VRPConsentRequestValidator.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/validator/VRPConsentRequestValidator.java
index cd4325b1..c69d5ded 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/validator/VRPConsentRequestValidator.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/validator/VRPConsentRequestValidator.java
@@ -249,7 +249,7 @@ public static JSONObject validateVRPInitiationPayload(JSONObject initiation) {
if (initiation.containsKey(ConsentExtensionConstants.DEBTOR_ACC)) {
JSONObject debtorAccount = (JSONObject) initiation.get(ConsentExtensionConstants.DEBTOR_ACC);
- JSONObject validationResult = ConsentManageUtil.validateVRPDebtorAccount(debtorAccount);
+ JSONObject validationResult = ConsentManageUtil.validateDebtorAccount(debtorAccount);
if (!(boolean) validationResult.get(ConsentExtensionConstants.IS_VALID)) {
return validationResult;
@@ -260,7 +260,7 @@ public static JSONObject validateVRPInitiationPayload(JSONObject initiation) {
if (initiation.containsKey(ConsentExtensionConstants.CREDITOR_ACC)) {
JSONObject creditorAccount = (JSONObject) initiation.get(ConsentExtensionConstants.CREDITOR_ACC);
- JSONObject validationResult = ConsentManageUtil.validateVRPCreditorAccount(creditorAccount);
+ JSONObject validationResult = ConsentManageUtil.validateCreditorAccount(creditorAccount);
if (!(boolean) validationResult.get(ConsentExtensionConstants.IS_VALID)) {
return validationResult;
From 04e4fad59d8beea51e4ff566008271e2c549afe1 Mon Sep 17 00:00:00 2001
From: kalpana
Date: Wed, 6 Dec 2023 17:36:33 +0530
Subject: [PATCH 025/281] VRP implementation
---
.../common/util/ErrorConstants.java | 41 +-
.../manage/impl/VRPConsentRequestHandler.java | 97 ++--
.../validator/VRPConsentRequestValidator.java | 492 ++++++++++++------
.../extensions/util/ConsentManageUtil.java | 316 ++---------
4 files changed, 478 insertions(+), 468 deletions(-)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java
index 78a9f1a7..586ca1ce 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java
@@ -1,13 +1,10 @@
/**
* Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
- *
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
- *
* http://www.apache.org/licenses/LICENSE-2.0
- *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -108,6 +105,7 @@ public class ErrorConstants {
public static final String PATH_CONSENT_ID = "Data.Initiation.Consent-id";
public static final String PATH_DATA = "Data";
public static final String PATH_INITIATION = "Data.Initiation";
+ public static final String PATH_CONTROL_PARAMETERS = "Data.ControlParameters";
public static final String PATH_RISK = "Data.Risk";
public static final String PATH_URL = "Data.Url";
public static final String PATH_EXPIRATION_DATE = "Data.Expiration-Date";
@@ -226,22 +224,39 @@ public class ErrorConstants {
public static final String FIELD_INVALID_DATE = "OB.Field.InvalidDate";
public static final String EXPIRED_DATE_ERROR = "The ExpirationDateTime value has to be a future date.";
// vrp
- public static final String MAXIMUM_INDIVIDUAL_AMOUNT_NOT_FOUND = "Mandatory parameter MaximumIndividualAmount" +
+ public static final String MAXIMUM_INDIVIDUAL_AMOUNT_IS_MISSING = "Mandatory parameter MaximumIndividualAmount" +
" Amount is missing in the payload.";
- public static final String PATH_MAXIMUM_INDIVIDUAL_CURRENCY = "Data.ControlParameters." +
- "MaximumIndividualAmount.Currency";
- public static final String MAXIMUM_INDIVIDUAL_AMOUNT_CURRENCY_NOT_FOUND = "Mandatory parameter " +
- "MaximumIndividualAmount Currency is missing in the payload";
- public static final String INVALID_MAXIMUM_INDIVIDUAL_AMOUNT = "Invalid value for Amount " +
- "in MaximumIndividualAmount";
+ public static final String MAXIMUM_INDIVIDUAL_AMOUNT_CURRENCY_IS_MISSING = "Mandatory parameter" +
+ "Currency in MaximumIndividualAmount is missing in the payload";
+ public static final String INVALID_AMOUNT = "Parameter in the payload for " +
+ "Amount" + "is missing in the payload or its null or not a string";
public static final String INVALID_CURRENCY = "Mandatory parameter " +
- "MaximumIndividualAmount Currency is missing in the payload";
+ "Currency is missing in the payload or its null or not a string";
public static final String INVALID_PERIOD_ALIGNMENT = "Invalid value for period alignment in PeriodicLimits";
- public static final String INVALID_PERIOD_TYPE = "Mandatory parameter " +
+ public static final String MISSING_PERIOD_TYPE = "Mandatory parameter " +
"period type is missing in the payload";
public static final String INVALID_VALID_TO_DATE = "Valid to Date specified in the request is invalid";
+
+ // new error constants
+ public static final String INVALID_PARAMETER = "Parameter passed in is null , " +
+ "empty or not a JSONObject";
+ public static final String INVALID_DATE_TIME_FORMAT = "Date and Time is not in correct JSON " +
+ "ISO-8601 date-time format";
+ public static final String INVALID_PARAMETER_PERIODIC_LIMITS = "Parameter passed in is null , " +
+ "empty or not a JSONArray";
+ public static final String MISSING_PERIOD_LIMITS = "Mandatory parameter " +
+ "periodic limits is missing in the payload";
+
public static final String PATH_VALID_TO_DATE = "Data.ControlParameters.ValidToDateTime";
- public static final String PATH_MAXIMUM_INDIVIDUAL_AMOUNT = "Data.ControlParameters.MaximumIndividualAmount.Amount";
+ public static final String PATH_VALID_FROM_DATE = "Data.ControlParameters.ValidFromDateTime";
+ public static final String PATH_MAXIMUM_INDIVIDUAL_AMOUNT = "Data.ControlParameters.MaximumIndividualAmount";
+ public static final String PATH_MAXIMUM_INDIVIDUAL_AMOUNT_AMOUNT = "Data.ControlParameters." +
+ "MaximumIndividualAmount.Amount";
+ public static final String PATH_MAXIMUM_INDIVIDUAL_AMOUNT_CURRENCY = "Data.ControlParameters." +
+ "MaximumIndividualAmount.Currency";
+ public static final String PATH_PERIOD_LIMIT = "Data.ControlParameters.PeriodicLimits";
+ public static final String PATH_PERIOD_LIMIT_AMOUNT = "Data.ControlParameters.PeriodicLimits.Amount";
+ public static final String PATH_PERIOD_LIMIT_CURRENCY = "Data.ControlParameters.PeriodicLimits.Currency";
public static final String PATH_PERIOD_TYPE = "Data.ControlParameters.PeriodicLimits.PeriodType";
public static final String PATH_PERIOD_ALIGNMENT = "Data.ControlParameters.PeriodLimits.PeriodAlignment";
}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/impl/VRPConsentRequestHandler.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/impl/VRPConsentRequestHandler.java
index 91d9677e..f103ff0c 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/impl/VRPConsentRequestHandler.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/impl/VRPConsentRequestHandler.java
@@ -1,13 +1,10 @@
/**
* Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
- *
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
- *
* http://www.apache.org/licenses/LICENSE-2.0
- *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -48,13 +45,15 @@
* Consent Manage request handler class for VRP Payment Request Validation.
*/
public class VRPConsentRequestHandler implements ConsentManageRequestHandler {
-
private static final Log log = LogFactory.getLog(VRPConsentRequestHandler.class);
-
/**
- * Method to handle Variable Recurring Payment Consent Manage Post Request.
+ * Method to handle Variable Recurring Payment Consent Manage POST Request.
+ * This method is responsible for processing a Variable Recurring Payment Consent Manage POST request.
+ * It validates the payment initiation request, checks for the existence of an idempotency key,
+ * and then delegates the handling to the specific payment initiation flows.
+ *
+ * @param consentManageData Object
*
- * @param consentManageData Object containing request details
*/
@Override
public void handleConsentManagePost(ConsentManageData consentManageData) {
@@ -62,15 +61,17 @@ public void handleConsentManagePost(ConsentManageData consentManageData) {
try {
//Get the request payload from the ConsentManageData
Object request = consentManageData.getPayload();
- if (!(request instanceof JSONObject)) {
- log.error(ErrorConstants.PAYLOAD_FORMAT_ERROR);
- throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.INVALID_REQ_PAYLOAD);
- }
- JSONObject requestObject = (JSONObject) request;
+ //Validate Payment Initiation request
+ JSONObject validationResponse = VRPConsentRequestValidator.validateVRPPayload(request);
- //Set request object to the response
- JSONObject response = requestObject;
+ //Throw an error if the initiation payload is not valid
+ if (!((boolean) validationResponse.get(ConsentExtensionConstants.IS_VALID))) {
+ log.error(ErrorConstants.PAYLOAD_INVALID);
+ throw new ConsentException((ResponseStatus) validationResponse
+ .get(ConsentExtensionConstants.HTTP_CODE),
+ String.valueOf(validationResponse.get(ConsentExtensionConstants.ERRORS)));
+ }
//Check Idempotency key exists
if (StringUtils.isEmpty(consentManageData.getHeaders()
@@ -79,7 +80,7 @@ public void handleConsentManagePost(ConsentManageData consentManageData) {
}
//Handle payment initiation flows
- handlePaymentPost(consentManageData, requestObject, response);
+ handlePaymentPost(consentManageData, request);
} catch (ConsentManagementException e) {
log.error("Error occurred while handling the initiation request", e);
@@ -89,6 +90,15 @@ public void handleConsentManagePost(ConsentManageData consentManageData) {
}
+ /**
+ * Method to handle Variable Recurring Payment Consent Manage POST Request.
+ * This method is responsible for processing a Variable Recurring Payment Consent Manage POST request.
+ * It validates the payment initiation request, checks for the existence of an idempotency key,
+ * and then delegates the handling to the specific payment initiation flows.
+ *
+ * @param consentManageData Object
+ *
+ */
@Override
public void handleConsentManageGet(ConsentManageData consentManageData) {
@@ -122,6 +132,16 @@ public void handleConsentManageGet(ConsentManageData consentManageData) {
}
}
+ /**
+ * Method to handle Variable Recurring Payment Consent Manage GET Request.
+ * This method retrieves and processes information related to a Variable Recurring Payment consent
+ * based on the provided consent ID. It validates the consent ID, checks if the consent exists,
+ * verifies if the consent belongs to the client making the request, and constructs a response payload
+ * containing relevant initiation retrieval details. The response status is set accordingly.
+ *
+ * @param consentManageData Object
+ *
+ */
@Override
public void handleConsentManageDelete(ConsentManageData consentManageData) {
@@ -129,64 +149,65 @@ public void handleConsentManageDelete(ConsentManageData consentManageData) {
}
/**
- * Method to handle the Variable Recurring Payment POST requests.
+ * Method to handle Variable Recurring Payment POST requests.
+ * This private method processes Variable Recurring Payment POST requests, creating a new consent
+ * based on the provided request payload. It performs the following actions:
+ * - Creates a DetailedConsentResource representing the consent initiation.
+ * - Stores consent attributes, including the idempotency key, for tracking and retrieval.
+ * - Constructs the response payload containing initiation details and sets appropriate headers.
+ * - Sets the response status to Create.
*
- * @param consentManageData Object containing request details
- * @param requestObject Request payload
- * @param response Response
+ * @param consentManageData Object containing request details, including client ID, request payload, headers,
+ * and other relevant information.
*/
- private void handlePaymentPost(ConsentManageData consentManageData, JSONObject requestObject, JSONObject response)
+ private void handlePaymentPost(ConsentManageData consentManageData, Object request)
throws ConsentManagementException {
+ // Variable to store the created consent
DetailedConsentResource createdConsent;
- //Validate Payment Initiation request
- JSONObject validationResponse = VRPConsentRequestValidator.validatePaymentInitiation(requestObject);
-
- //Throw an error if the initiation payload is not valid
- if (!((boolean) validationResponse.get(ConsentExtensionConstants.IS_VALID))) {
-
- log.error(ErrorConstants.PAYLOAD_INVALID);
- throw new ConsentException((ResponseStatus) validationResponse
- .get(ConsentExtensionConstants.HTTP_CODE),
- String.valueOf(validationResponse.get(ConsentExtensionConstants.ERRORS)));
- }
-
+ JSONObject requestObject = (JSONObject) request;
+ // Create a ConsentResource representing the requested consent
ConsentResource requestedConsent = new ConsentResource(consentManageData.getClientId(),
requestObject.toJSONString(), ConsentExtensionConstants.VRP,
ConsentExtensionConstants.AWAITING_AUTH_STATUS);
+ // Create the consent and retrieve the detailed consent resource
createdConsent = ConsentExtensionsDataHolder.getInstance().getConsentCoreService()
.createAuthorizableConsent(requestedConsent, null,
CREATED_STATUS, AUTH_TYPE_AUTHORIZATION, true);
//Set consent attributes for storing
- Map consentAttributes = new HashMap();
+ Map consentAttributes = new HashMap<>();
consentAttributes.put(ConsentExtensionConstants.IDEMPOTENCY_KEY, consentManageData.getHeaders()
.get(ConsentExtensionConstants.X_IDEMPOTENCY_KEY));
//Store consent attributes
ConsentServiceUtil.getConsentService().storeConsentAttributes(createdConsent.getConsentID(),
consentAttributes);
- consentManageData.setResponsePayload(ConsentManageUtil.getInitiationResponse(response, createdConsent,
+ consentManageData.setResponsePayload(ConsentManageUtil.getInitiationResponse(requestObject, createdConsent,
consentManageData, ConsentExtensionConstants.VRP_PAYMENT));
//Set Control Parameters as consent attributes to store
JSONObject controlParameters = (JSONObject) ((JSONObject) ((JSONObject) consentManageData.getPayload())
.get(ConsentExtensionConstants.DATA)).get(ConsentExtensionConstants.CONTROL_PARAMETERS);
- consentAttributes.put(ConsentExtensionConstants.MAXIMUM_INDIVIDUAL_AMOUNT, ((JSONObject) (controlParameters)
+
+ consentAttributes.put(ConsentExtensionConstants.MAXIMUM_INDIVIDUAL_AMOUNT,
+ ((JSONObject) (controlParameters)
.get(ConsentExtensionConstants.MAXIMUM_INDIVIDUAL_AMOUNT)).get(ConsentExtensionConstants.AMOUNT)
.toString());
+ consentAttributes.put(ConsentExtensionConstants.PERIOD_ALIGNMENT, ((JSONObject) ((JSONArray)
+ (controlParameters).get(ConsentExtensionConstants.PERIODIC_LIMITS)).get(0))
+ .get(ConsentExtensionConstants.PERIOD_ALIGNMENT).toString());
consentAttributes.put(ConsentExtensionConstants.PERIOD_TYPE, ((JSONObject) ((JSONArray) (controlParameters)
.get(ConsentExtensionConstants.PERIODIC_LIMITS)).get(0)).get(ConsentExtensionConstants.PERIOD_TYPE)
.toString());
- consentAttributes.put(ConsentExtensionConstants.PERIOD_ALIGNMENT, ((JSONObject) ((JSONArray) (controlParameters)
- .get(ConsentExtensionConstants.PERIODIC_LIMITS)).get(0)).get(ConsentExtensionConstants.PERIOD_TYPE)
- .toString());
consentAttributes.put(ConsentExtensionConstants.PERIOD_AMOUNT_LIMIT, ((JSONObject)
((JSONArray) (controlParameters).get(ConsentExtensionConstants.PERIODIC_LIMITS)).get(0))
.get(ConsentExtensionConstants.PERIOD_AMOUNT_LIMIT).toString());
+ // Get request headers
Map headers = consentManageData.getHeaders();
+
//Setting response headers
//Setting created time and idempotency to headers to handle idempotency in Gateway
consentManageData.setResponseHeader(ConsentExtensionConstants.X_IDEMPOTENCY_KEY,
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/validator/VRPConsentRequestValidator.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/validator/VRPConsentRequestValidator.java
index c69d5ded..018ae9ca 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/validator/VRPConsentRequestValidator.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/validator/VRPConsentRequestValidator.java
@@ -1,23 +1,21 @@
/**
* Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
- *
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
- *
* http://www.apache.org/licenses/LICENSE-2.0
- *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
+ *
*/
-
package com.wso2.openbanking.accelerator.consent.extensions.manage.validator;
import com.wso2.openbanking.accelerator.common.util.ErrorConstants;
+import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentException;
import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentExtensionConstants;
import com.wso2.openbanking.accelerator.consent.extensions.common.ResponseStatus;
import com.wso2.openbanking.accelerator.consent.extensions.util.ConsentManageUtil;
@@ -28,217 +26,397 @@
import org.apache.commons.logging.LogFactory;
import java.time.OffsetDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
import java.util.Iterator;
-
/**
* Consent Manage validator class for Variable Recurring Payment Request Validation.
*/
public class VRPConsentRequestValidator {
private static final Log log = LogFactory.getLog(VRPConsentRequestValidator.class);
+
/**
- * Method to validate variable recurring payment control parameters.
+ * Method to validate a variable recurring payment request.
+ * This method performs validation on the variable recurring payment request.
+ * It checks the validity of the initiation data body, the initiation payload, control parameters,
+ * and ensures that the risk information is present. If any validation fails, the method returns a detailed
+ * validation response indicating the error. If all validations pass, the returned validation response
+ * indicates that the initiation request is valid.
*
- * @param controlParameters Initiation Object
- * @return validation response object
+ * @param request The initiation object containing the variable recurring payment initiation request.
+ * @return A validation response object indicating whether the initiation request is valid.
*/
- public static JSONObject validatecontrolParameters(JSONObject controlParameters) {
+ public static JSONObject validateVRPPayload(Object request) {
+
+ JSONObject validationResponse = new JSONObject();
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
+
+ //Get the request payload from the ConsentManageData
+ if (!(request instanceof JSONObject)) {
+ log.error(ErrorConstants.PAYLOAD_FORMAT_ERROR);
+ throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.INVALID_REQ_PAYLOAD);
+ }
+ JSONObject requestBody = (JSONObject) request;
+ //Check request body is valid and not empty
+ JSONObject dataValidationResult = ConsentManageUtil.validateInitiationDataBody(requestBody);
+
+ if (!(boolean) dataValidationResult.get(ConsentExtensionConstants.IS_VALID)) {
+ log.error(dataValidationResult.get(ConsentExtensionConstants.ERRORS));
+ return dataValidationResult;
+ }
+
+ JSONObject data = (JSONObject) requestBody.get(ConsentExtensionConstants.DATA);
+
+ //Validate initiation in the VRP payload
+ if (data.containsKey(ConsentExtensionConstants.INITIATION)) {
+
+ Object initiation = data.get(ConsentExtensionConstants.INITIATION);
+
+ if (!isValidObject(initiation)) {
+ return ConsentManageUtil.getValidationResponse(ErrorConstants.INVALID_REQ_PAYLOAD,
+ ErrorConstants.INVALID_PARAMETER,
+ ErrorConstants.PATH_INITIATION);
+ }
+
+ JSONObject initiationValidationResult = VRPConsentRequestValidator
+ .validateVRPInitiationPayload((JSONObject) data.get(ConsentExtensionConstants.INITIATION));
+
+ if (!(boolean) initiationValidationResult.get(ConsentExtensionConstants.IS_VALID)) {
+ log.error(initiationValidationResult.get(ConsentExtensionConstants.ERRORS));
+ return initiationValidationResult;
+ }
+ } else {
+ log.error(ErrorConstants.PAYLOAD_FORMAT_ERROR);
+ return ConsentManageUtil.getValidationResponse(ErrorConstants.RESOURCE_INVALID_FORMAT,
+ ErrorConstants.PAYLOAD_FORMAT_ERROR, ErrorConstants.PATH_REQUEST_BODY);
+ }
+
+ //Validate the ControlParameter in the payload
+ if (data.containsKey(ConsentExtensionConstants.CONTROL_PARAMETERS)) {
+
+ Object controlParameters = data.get(ConsentExtensionConstants.CONTROL_PARAMETERS);
+
+ if (!isValidObject(controlParameters)) {
+ return ConsentManageUtil.getValidationResponse(ErrorConstants.INVALID_REQ_PAYLOAD,
+ ErrorConstants.INVALID_PARAMETER,
+ ErrorConstants.PATH_INITIATION);
+ }
+
+ JSONObject controlParameterValidationResult =
+ VRPConsentRequestValidator.validateControlParameters((JSONObject)
+ data.get(ConsentExtensionConstants.CONTROL_PARAMETERS));
+
+ if (!(boolean) controlParameterValidationResult.get(ConsentExtensionConstants.IS_VALID)) {
+ log.error(controlParameterValidationResult.get(ConsentExtensionConstants.ERRORS));
+ return controlParameterValidationResult;
+ }
+ } else {
+ log.error(ErrorConstants.PAYLOAD_FORMAT_ERROR);
+ return ConsentManageUtil.getValidationResponse(ErrorConstants.RESOURCE_INVALID_FORMAT,
+ ErrorConstants.PAYLOAD_FORMAT_ERROR, ErrorConstants.PATH_REQUEST_BODY);
+ }
+
+ // check risk is mandatory
+ if (!requestBody.containsKey(ConsentExtensionConstants.RISK) ||
+ !(requestBody.get(ConsentExtensionConstants.RISK) instanceof JSONObject
+ || ((JSONObject) requestBody.get(ConsentExtensionConstants.DATA)).isEmpty())) {
+ log.error(ErrorConstants.PAYLOAD_FORMAT_ERROR);
+ return ConsentManageUtil.getValidationResponse(ErrorConstants.RESOURCE_INVALID_FORMAT,
+ ErrorConstants.PAYLOAD_FORMAT_ERROR, ErrorConstants.PATH_REQUEST_BODY);
+ }
+
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, true);
+ return validationResponse;
+ }
+
+ /**
+ * Checks if the given Object is a non-null and non-empty JSONObject.
+ *
+ * @param value The Object to be validated.
+ * @return value
+ */
+ public static boolean isValidObject(Object value) {
+ return value instanceof JSONObject && !((JSONObject) value).isEmpty();
+ }
+
+
+ /**
+ * Checks if the given Object is a non-null and non-empty JSONObject.
+ *
+ * @param validToDateTime The Object to be validated.
+ * @return value
+ */
+ public static boolean isValidDateTimeObject(Object validFromDateTime, Object validToDateTime) {
+ return validFromDateTime instanceof JSONObject && !((JSONObject) validToDateTime).isEmpty() &&
+ validFromDateTime instanceof JSONObject && !((JSONObject) validToDateTime).isEmpty();
+ }
+
+
+
+ /**
+ * Method to validate control parameters for variable recurring payments.
+ * This method performs comprehensive validation on the control parameters for variable recurring payments.
+ * It checks the validity of maximum individual amount, requested execution date-time, and periodic limits.
+ * If any validation fails, the method returns a detailed validation response indicating the error.
+ * If all validations pass, the returned validation response indicates that the control parameters are valid.
+ *
+ * @param controlParameters The initiation object containing control parameters for variable recurring payments.
+ * @return A validation response object indicating whether the control parameters are valid.
+ */
+
+ public static JSONObject validateControlParameters(JSONObject controlParameters) {
JSONObject validationResponse = new JSONObject();
//Validate Maximum individual amount in control parameters
if (controlParameters.containsKey(ConsentExtensionConstants.MAXIMUM_INDIVIDUAL_AMOUNT)) {
- JSONObject maximumIndividualAmount = (JSONObject) controlParameters
- .get(ConsentExtensionConstants.MAXIMUM_INDIVIDUAL_AMOUNT);
- String amount = maximumIndividualAmount.getAsString(ConsentExtensionConstants.AMOUNT);
- String currency = maximumIndividualAmount.getAsString(ConsentExtensionConstants.CURRENCY);
-
- // validate amount
- if (!ConsentManageUtil.validateMaximumIndividualAmount(maximumIndividualAmount)) {
- log.error(ErrorConstants.INVALID_MAXIMUM_INDIVIDUAL_AMOUNT);
- return ConsentManageUtil.getValidationResponse(ErrorConstants.FIELD_INVALID,
- ErrorConstants.INVALID_MAXIMUM_INDIVIDUAL_AMOUNT,
+
+ Object maximumIndividualAmount = controlParameters.get(ConsentExtensionConstants.MAXIMUM_INDIVIDUAL_AMOUNT);
+ // Check if the control parameter is valid
+ if (!isValidObject(maximumIndividualAmount)) {
+ return ConsentManageUtil.getValidationResponse(ErrorConstants.PAYLOAD_FORMAT_ERROR,
+ ErrorConstants.INVALID_PARAMETER,
ErrorConstants.PATH_MAXIMUM_INDIVIDUAL_AMOUNT);
}
- if (StringUtils.isEmpty(amount)) {
- log.error(ErrorConstants.MAXIMUM_INDIVIDUAL_AMOUNT_NOT_FOUND);
- validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
- validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
- validationResponse.put(ConsentExtensionConstants.ERRORS,
- ErrorConstants.MAXIMUM_INDIVIDUAL_AMOUNT_NOT_FOUND);
- return validationResponse;
+ Object amount = ((JSONObject) maximumIndividualAmount).getAsString(ConsentExtensionConstants.AMOUNT);
+
+ Object currency = ((JSONObject) maximumIndividualAmount).getAsString(ConsentExtensionConstants.CURRENCY);
+
+ // check whether the amount key is present in the payload and its not null
+ if (!ConsentManageUtil.validateAmount((JSONObject)
+ maximumIndividualAmount)) {
+ return ConsentManageUtil.getValidationResponse(ErrorConstants.PAYLOAD_FORMAT_ERROR,
+ ErrorConstants.INVALID_AMOUNT,
+ ErrorConstants.PATH_MAXIMUM_INDIVIDUAL_AMOUNT_AMOUNT);
+ }
+
+ if (StringUtils.isEmpty((String) amount)) {
+ return ConsentManageUtil.getValidationResponse(ErrorConstants.PAYLOAD_FORMAT_ERROR,
+ ErrorConstants.MAXIMUM_INDIVIDUAL_AMOUNT_IS_MISSING,
+ ErrorConstants.PATH_MAXIMUM_INDIVIDUAL_AMOUNT_AMOUNT);
+ }
+
+ // check whether the Currency key is present in the payload and its not null
+ if (!ConsentManageUtil.validateCurrency((JSONObject)
+ maximumIndividualAmount)) {
+ return ConsentManageUtil.getValidationResponse(ErrorConstants.PAYLOAD_FORMAT_ERROR,
+ ErrorConstants.INVALID_CURRENCY,
+ ErrorConstants.PATH_MAXIMUM_INDIVIDUAL_AMOUNT_CURRENCY);
}
- //validate currency
- if (!ConsentManageUtil.validateMaximumIndividualAmountCurrency(maximumIndividualAmount)) {
- log.error(ErrorConstants.INVALID_CURRENCY);
- validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
- validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
- validationResponse.put(ConsentExtensionConstants.ERRORS,
+ if (StringUtils.isEmpty((String) currency)) {
+ return ConsentManageUtil.getValidationResponse(ErrorConstants.PAYLOAD_FORMAT_ERROR,
+ ErrorConstants.MAXIMUM_INDIVIDUAL_AMOUNT_CURRENCY_IS_MISSING,
ErrorConstants.PATH_MAXIMUM_INDIVIDUAL_AMOUNT);
- return ConsentManageUtil.getValidationResponse(ErrorConstants.FIELD_INVALID,
- ErrorConstants.INVALID_CURRENCY, ErrorConstants.PATH_MAXIMUM_INDIVIDUAL_AMOUNT);
}
-
- if (StringUtils.isEmpty(currency)) {
- log.error(ErrorConstants.MAXIMUM_INDIVIDUAL_AMOUNT_CURRENCY_NOT_FOUND);
- validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
- validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
- validationResponse.put(ConsentExtensionConstants.ERRORS,
- ErrorConstants.MAXIMUM_INDIVIDUAL_AMOUNT_CURRENCY_NOT_FOUND);
- return validationResponse;
+ } else {
+ log.error(ErrorConstants.PAYLOAD_FORMAT_ERROR);
+ throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.INVALID_REQ_PAYLOAD);
}
+
+ // Validate ValidToDateTime and ValidFromDateTime
+ JSONObject periodicLimits = validateParameterDateTime(controlParameters);
+ if (!(boolean) periodicLimits.get(ConsentExtensionConstants.IS_VALID)) {
+ log.error(periodicLimits.get(ConsentExtensionConstants.ERRORS));
+ return periodicLimits;
+ }
+
+ // Validate Periodic Limits
+ JSONObject periodicLimitsValidationResult = validatePeriodicLimits(controlParameters);
+ if (!(boolean) periodicLimitsValidationResult.get(ConsentExtensionConstants.IS_VALID)) {
+ log.error(periodicLimitsValidationResult.get(ConsentExtensionConstants.ERRORS));
+ return periodicLimitsValidationResult;
}
- //Validate RequestedExecutionDateTime in controlParameters
- if (controlParameters.containsKey(ConsentExtensionConstants.VALID_TO_DATE_TIME)) {
+ validationResponse.put(ConsentExtensionConstants.IS_VALID, true);
+ return validationResponse;
+ }
- String validTo = controlParameters.getAsString(ConsentExtensionConstants.VALID_TO_DATE_TIME);
- String validFrom = controlParameters.getAsString(ConsentExtensionConstants.VALID_FROM_DATE_TIME);
+ /**
+ * Checks whether the given object is a valid JSONArray.
+ * This method verifies if the provided object is not null and is an instance of JSONArray.
+ * It is commonly used to validate whether a given object represents a valid JSON array.
+ *
+ * @param value The object to be checked for being a valid JSONArray.
+ */
+ public static boolean isValidJSONArray(Object value) {
+ return value instanceof JSONArray;
+ }
- OffsetDateTime validToDateTime = OffsetDateTime.parse(validTo);
- OffsetDateTime validFromDateTime = OffsetDateTime.parse(validFrom);
- OffsetDateTime currentDateTime = OffsetDateTime.now(validToDateTime.getOffset());
- //If the ValidToDAte is older than current date OR ValidToDAte is older than ValidFromDAte, return error
- if (currentDateTime.isAfter(validToDateTime) || validFromDateTime.isAfter(validToDateTime)) {
- log.error(ErrorConstants.INVALID_VALID_TO_DATE);
- return ConsentManageUtil.getValidationResponse(ErrorConstants.FIELD_INVALID,
- ErrorConstants.INVALID_VALID_TO_DATE, ErrorConstants.PATH_VALID_TO_DATE);
- }
+ /**
+ * Checks whether the given string represents a valid date-time in ISO-8601 format.
+ *
+ * This method uses the ISO_DATE_TIME formatter to parse the provided date-time string.
+ * It returns true if the parsing is successful, indicating that the string is in the correct
+ * ISO-8601 date-time format. Otherwise, it returns false.
+ *
+ * @param dateTimeString The string to be checked for ISO-8601 date-time format validity.
+ * @return
+ */
+ public static boolean isValidISODateTimeFormat(String dateTimeString) {
+
+ final DateTimeFormatter dateTimeFormat = DateTimeFormatter.ISO_DATE_TIME;
+
+ try {
+ dateTimeFormat.parse(dateTimeString);
+ return true;
+ } catch (DateTimeParseException e) {
+ return false;
}
+ }
+
+ /**
+ * Method to validate variable recurring payment periodic limits.
+ * This method validates the periodic limits specified in the control parameters for variable recurring payments.
+ * It checks if the provided JSON array of periodic limits is valid and then iterates through each limit
+ * to ensure that required fields such as amount, currency, period alignment, and period type are present and
+ * meet the specified criteria.
+ *
+ * @param controlParameters Initiation Object containing periodic limits
+ * @return validation response object indicating whether the provided periodic limits are valid
+ */
+ public static JSONObject validatePeriodicLimits(JSONObject controlParameters) {
+ JSONObject validationResponse = new JSONObject();
- //Validate periodic limits in control parameters
+ // Retrieve the periodic limits from the control parameters
+ Object periodicLimit = controlParameters.get(ConsentExtensionConstants.PERIODIC_LIMITS);
+
+ // Check if the control parameter is a valid JSON array
+ if (!isValidJSONArray(periodicLimit)) {
+ return ConsentManageUtil.getValidationResponse(ErrorConstants.PAYLOAD_FORMAT_ERROR,
+ ErrorConstants.INVALID_PARAMETER_PERIODIC_LIMITS,
+ ErrorConstants.PATH_PERIOD_LIMIT);
+ }
+
+ // Check if the periodic limits key is present
if (controlParameters.containsKey(ConsentExtensionConstants.PERIODIC_LIMITS)) {
+
+ // Retrieve the JSON array of periodic limits
JSONArray periodicLimits = (JSONArray) controlParameters.get(ConsentExtensionConstants.PERIODIC_LIMITS);
- Iterator it = periodicLimits.iterator();
- while (it.hasNext()) {
- JSONObject limit = (JSONObject) it.next();
+ // Iterate through each periodic limit
+ Iterator
-
- org.wso2.carbon.identity.framework
- org.wso2.carbon.identity.application.mgt.stub
- org.mockitomockito-all
@@ -204,8 +200,6 @@
org.wso2.carbon.apimgt.impl;version="${org.wso2.carbon.apimgt.version.range}",
org.wso2.carbon.apimgt.impl.jwt;version="${org.wso2.carbon.apimgt.version.range}",
org.wso2.carbon.authenticator.stub;version="${carbon.kernel.version.range}",
- org.wso2.carbon.identity.application.common.model.xsd;version="${carbon.identity.framework.version.range}",
- org.wso2.carbon.identity.application.mgt.stub;version="${carbon.identity.framework.version.range}",
org.wso2.carbon.user.mgt.stub;version="${carbon.identity.framework.version.range}",
org.wso2.carbon.identity.oauth.stub;version="${org.wso2.carbon.identity.oauth.stub.version.range}",
org.wso2.carbon.identity.oauth.stub.dto;version="${org.wso2.carbon.identity.oauth.stub.version.range}",
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/src/main/java/com/wso2/openbanking/accelerator/keymanager/KeyManagerUtil.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/src/main/java/com/wso2/openbanking/accelerator/keymanager/KeyManagerUtil.java
index 6ef68c55..fed1c6be 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/src/main/java/com/wso2/openbanking/accelerator/keymanager/KeyManagerUtil.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/src/main/java/com/wso2/openbanking/accelerator/keymanager/KeyManagerUtil.java
@@ -59,7 +59,10 @@ public class KeyManagerUtil {
*
* @return Session cookie as a String
* @throws APIManagementException When failed to obtain the session cookie
+ * @deprecated ApplicationManagementService is used instead of SOAP API calls.
*/
+ @Deprecated
+ @Generated(message = "Excluding from unit test coverage")
public static String getSessionCookie() throws APIManagementException {
String sessionCookie = "";
@@ -90,7 +93,10 @@ public static String getSessionCookie() throws APIManagementException {
*
* @param serviceClient Admin service client
* @param sessionCookie session cookie as a string
+ * @deprecated ApplicationManagementService is used instead of SOAP API calls.
*/
+ @Deprecated
+ @Generated(message = "Excluding from unit test coverage")
public static void setAdminServiceSession(ServiceClient serviceClient, String sessionCookie) {
Options userAdminOption = serviceClient.getOptions();
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/src/main/java/com/wso2/openbanking/accelerator/keymanager/OBKeyManagerImpl.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/src/main/java/com/wso2/openbanking/accelerator/keymanager/OBKeyManagerImpl.java
index 306eb6ac..ee86cf1c 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/src/main/java/com/wso2/openbanking/accelerator/keymanager/OBKeyManagerImpl.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/src/main/java/com/wso2/openbanking/accelerator/keymanager/OBKeyManagerImpl.java
@@ -26,7 +26,6 @@
import net.minidev.json.JSONObject;
import net.minidev.json.parser.JSONParser;
import net.minidev.json.parser.ParseException;
-import org.apache.axis2.client.ServiceClient;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -42,16 +41,13 @@
import org.wso2.carbon.apimgt.impl.AMDefaultKeyManagerImpl;
import org.wso2.carbon.apimgt.impl.APIConstants;
import org.wso2.carbon.identity.application.common.IdentityApplicationManagementException;
-import org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider;
-import org.wso2.carbon.identity.application.common.model.xsd.ServiceProviderProperty;
+import org.wso2.carbon.identity.application.common.model.ServiceProvider;
+import org.wso2.carbon.identity.application.common.model.ServiceProviderProperty;
+import org.wso2.carbon.identity.application.common.util.IdentityApplicationConstants;
import org.wso2.carbon.identity.application.mgt.ApplicationManagementServiceImpl;
-import org.wso2.carbon.identity.application.mgt.stub.IdentityApplicationManagementServiceIdentityApplicationManagementException;
import org.wso2.carbon.identity.oauth.IdentityOAuthAdminException;
import org.wso2.carbon.identity.oauth.OAuthAdminService;
-import org.wso2.carbon.identity.oauth.stub.OAuthAdminServiceIdentityOAuthAdminException;
-import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO;
-import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -65,45 +61,24 @@ public class OBKeyManagerImpl extends AMDefaultKeyManagerImpl implements OBKeyMa
private static final Log log = LogFactory.getLog(OBKeyManagerImpl.class);
+ public static final String OAUTH2 = "oauth2";
+
@Override
public AccessTokenInfo getNewApplicationAccessToken(AccessTokenRequest tokenRequest) throws APIManagementException {
try {
- String applicationName = "";
- String sessionCookie = KeyManagerUtil.getSessionCookie();
- ServiceClient userAdminClient = KeyManagerDataHolder.getInstance()
- .getUserAdminStub()._getServiceClient();
- KeyManagerUtil.setAdminServiceSession(userAdminClient, sessionCookie);
-
- ServiceClient oauthAppClient = KeyManagerDataHolder.getInstance().getOauthAdminServiceStub()
- ._getServiceClient();
- KeyManagerUtil.setAdminServiceSession(oauthAppClient, sessionCookie);
-
- OAuthConsumerAppDTO oAuthConsumerAppDTO = KeyManagerDataHolder.getInstance().getOauthAdminServiceStub()
- .getOAuthApplicationData(tokenRequest.getClientId());
-
- if (oAuthConsumerAppDTO != null) {
- applicationName = oAuthConsumerAppDTO.getApplicationName();
- }
-
- ServiceClient appMgtClient = KeyManagerDataHolder.getInstance()
- .getIdentityApplicationManagementServiceStub()._getServiceClient();
- KeyManagerUtil.setAdminServiceSession(appMgtClient, sessionCookie);
-
- ServiceProvider serviceProvider = KeyManagerDataHolder.getInstance()
- .getIdentityApplicationManagementServiceStub().getApplication(applicationName);
- ServiceProviderProperty[] serviceProviderProperties = serviceProvider.getSpProperties();
- List spProperties = new ArrayList<>(Arrays.asList(serviceProviderProperties));
-
- ServiceProviderProperty regulatoryProperty = spProperties.stream()
- .filter(serviceProviderProperty -> serviceProviderProperty.getName()
- .equalsIgnoreCase(OpenBankingConstants.REGULATORY)).findAny().orElse(null);
-
- if (regulatoryProperty != null && "true".equalsIgnoreCase(regulatoryProperty.getValue())) {
- return null;
+ ApplicationManagementServiceImpl applicationManagementService = getApplicationMgmtServiceImpl();
+ ServiceProvider serviceProvider = applicationManagementService.getServiceProviderByClientId(
+ tokenRequest.getClientId(), IdentityApplicationConstants.OAuth2.NAME, tenantDomain);
+ if (serviceProvider != null) {
+ ServiceProviderProperty regulatoryProperty = Arrays.stream(serviceProvider.getSpProperties())
+ .filter(serviceProviderProperty -> serviceProviderProperty.getName()
+ .equalsIgnoreCase(OpenBankingConstants.REGULATORY)).findAny().orElse(null);
+ if (regulatoryProperty != null && "true".equalsIgnoreCase(regulatoryProperty.getValue())) {
+ return null;
+ }
}
- } catch (RemoteException | IdentityApplicationManagementServiceIdentityApplicationManagementException |
- OAuthAdminServiceIdentityOAuthAdminException e) {
+ } catch (IdentityApplicationManagementException e) {
log.error("Error while generating keys. ", e);
}
return super.getNewApplicationAccessToken(tokenRequest);
@@ -239,16 +214,16 @@ public OAuthApplicationInfo createApplication(OAuthAppRequest oauthAppRequest) t
String tenantDomain = ServiceProviderUtils.getSpTenantDomain(oAuthApplicationInfo.getClientId());
updateSpProperties(appName, tenantDomain, username, additionalProperties, true);
- org.wso2.carbon.identity.application.common.model.ServiceProvider appServiceProvider =
- getApplicationMgmtServiceImpl().getServiceProvider(appName, tenantDomain);
- org.wso2.carbon.identity.application.common.model.ServiceProviderProperty regulatoryProperty =
- getSpPropertyFromSPMetaData(OpenBankingConstants.REGULATORY, appServiceProvider.getSpProperties());
+ ServiceProvider appServiceProvider = getApplicationMgmtServiceImpl()
+ .getServiceProvider(appName, tenantDomain);
+ ServiceProviderProperty regulatoryProperty = getSpPropertyFromSPMetaData(
+ OpenBankingConstants.REGULATORY, appServiceProvider.getSpProperties());
if (regulatoryProperty != null) {
if (Boolean.parseBoolean(regulatoryProperty.getValue())) {
OAuthAppRequest updatedOauthAppRequest = oauthAppRequest;
- org.wso2.carbon.identity.application.common.model.ServiceProviderProperty appNameProperty =
- getSpPropertyFromSPMetaData("DisplayName", appServiceProvider.getSpProperties());
+ ServiceProviderProperty appNameProperty = getSpPropertyFromSPMetaData("DisplayName",
+ appServiceProvider.getSpProperties());
if (appNameProperty != null) {
updatedOauthAppRequest.getOAuthApplicationInfo().setClientName(appNameProperty.getValue());
}
@@ -280,16 +255,16 @@ public OAuthApplicationInfo updateApplication(OAuthAppRequest oAuthAppRequest) t
String clientId = oAuthApplicationInfo.getClientId();
// There is no way to identify the client type in here. So we have to hardcode "oauth2" as the client type
try {
- org.wso2.carbon.identity.application.common.model.ServiceProvider serviceProvider =
- getApplicationMgmtServiceImpl().getServiceProviderByClientId(clientId, "oauth2", tenantDomain);
+ ServiceProvider serviceProvider = getApplicationMgmtServiceImpl()
+ .getServiceProviderByClientId(clientId, OAUTH2, tenantDomain);
doPreUpdateApplication(oAuthAppRequest, additionalProperties, serviceProvider);
String appName = serviceProvider.getApplicationName();
String username = (String) oAuthApplicationInfo.getParameter(ApplicationConstants.OAUTH_CLIENT_USERNAME);
updateSpProperties(appName, tenantDomain, username, additionalProperties, false);
} catch (IdentityApplicationManagementException e) {
String errMsg = "Cannot find Service provider application for client Id " + clientId;
- log.error(errMsg);
- throw new APIManagementException(errMsg, ExceptionCodes.OAUTH2_APP_RETRIEVAL_FAILED);
+ log.error(errMsg);
+ throw new APIManagementException(errMsg, ExceptionCodes.OAUTH2_APP_RETRIEVAL_FAILED);
}
oAuthApplicationInfo = super.updateApplication(oAuthAppRequest);
@@ -308,7 +283,7 @@ public OAuthApplicationInfo retrieveApplication(String consumerKey) throws APIMa
getApplicationMgmtServiceImpl().getServiceProvider(name, tenantDomain);
// Iterate OB specific additional properties to check whether they override the value of any predefined
// sp properties in application management listeners
- List spProperties =
+ List spProperties =
new ArrayList<>(Arrays.asList(appServiceProvider.getSpProperties()));
return updateAdditionalProperties(oAuthApplicationInfo, spProperties);
} catch (IdentityApplicationManagementException | OpenBankingException e) {
@@ -332,33 +307,30 @@ protected void updateSpProperties(String spAppName, String tenantDomain, String
try {
org.wso2.carbon.identity.oauth.dto.OAuthConsumerAppDTO oAuthConsumerAppDTO = getOAuthAdminService().
getOAuthApplicationDataByAppName(spAppName);
- org.wso2.carbon.identity.application.common.model.ServiceProvider serviceProvider =
- getApplicationMgmtServiceImpl().getServiceProvider(spAppName, tenantDomain);
-
+ ServiceProvider serviceProvider = getApplicationMgmtServiceImpl()
+ .getServiceProvider(spAppName, tenantDomain);
doPreUpdateSpApp(oAuthConsumerAppDTO, serviceProvider, additionalProperties, isCreateApp);
// Iterate OB specific additional properties to check whether they override the value of any predefined
// sp properties in application management listeners
- List spProperties =
+ List spProperties =
new ArrayList<>(Arrays.asList(serviceProvider.getSpProperties()));
for (Map.Entry propertyElement : additionalProperties.entrySet()) {
- org.wso2.carbon.identity.application.common.model.ServiceProviderProperty overridenSPproperty
- = spProperties.stream().filter(serviceProviderProperty -> serviceProviderProperty.getName()
- .equalsIgnoreCase(propertyElement.getKey())).findAny().orElse(null);
+ ServiceProviderProperty overridenSPproperty = spProperties.stream().filter(
+ serviceProviderProperty -> serviceProviderProperty.getName()
+ .equalsIgnoreCase(propertyElement.getKey())).findAny().orElse(null);
// If SP property is overridden, remove old SP property and add the new one
if (overridenSPproperty != null) {
spProperties.remove(overridenSPproperty);
overridenSPproperty.setValue(propertyElement.getValue());
spProperties.add(overridenSPproperty);
} else {
- org.wso2.carbon.identity.application.common.model.ServiceProviderProperty additionalProperty =
- new org.wso2.carbon.identity.application.common.model.ServiceProviderProperty();
+ ServiceProviderProperty additionalProperty = new ServiceProviderProperty();
additionalProperty.setName(propertyElement.getKey());
additionalProperty.setValue(propertyElement.getValue());
spProperties.add(additionalProperty);
}
}
- serviceProvider.setSpProperties(spProperties.toArray(
- new org.wso2.carbon.identity.application.common.model.ServiceProviderProperty[0]));
+ serviceProvider.setSpProperties(spProperties.toArray(new ServiceProviderProperty[0]));
try {
getApplicationMgmtServiceImpl().updateApplication(serviceProvider, tenantDomain, username);
if (log.isDebugEnabled()) {
@@ -395,13 +367,12 @@ protected void updateSpProperties(String spAppName, String tenantDomain, String
* @return oAuth application Info
*/
protected OAuthApplicationInfo updateAdditionalProperties(OAuthApplicationInfo oAuthApplicationInfo,
- List spProperties) {
+ List spProperties) {
Map> keyManagerAdditionalProperties = OpenBankingConfigParser.getInstance()
.getKeyManagerAdditionalProperties();
for (String key : keyManagerAdditionalProperties.keySet()) {
- for (org.wso2.carbon.identity.application.common.model.ServiceProviderProperty spProperty : spProperties) {
+ for (ServiceProviderProperty spProperty : spProperties) {
if (spProperty.getName().equalsIgnoreCase(key)) {
((HashMap) oAuthApplicationInfo.getParameter(
APIConstants.JSON_ADDITIONAL_PROPERTIES)).put(key, spProperty.getValue());
@@ -421,8 +392,7 @@ protected OAuthApplicationInfo updateAdditionalProperties(OAuthApplicationInfo o
public void validateAdditionalProperties(Map obAdditionalProperties)
throws APIManagementException {
- OBKeyManagerExtensionInterface obKeyManagerExtensionImpl = KeyManagerUtil
- .getOBKeyManagerExtensionImpl();
+ OBKeyManagerExtensionInterface obKeyManagerExtensionImpl = KeyManagerUtil.getOBKeyManagerExtensionImpl();
if (obKeyManagerExtensionImpl != null) {
obKeyManagerExtensionImpl.validateAdditionalProperties(obAdditionalProperties);
}
@@ -437,8 +407,7 @@ public void validateAdditionalProperties(Map obAdditio
@Generated(message = "Excluding from code coverage since the method body is at toolkit")
public void doPreCreateApplication(OAuthAppRequest oAuthAppRequest, HashMap additionalProperties)
throws APIManagementException {
- OBKeyManagerExtensionInterface obKeyManagerExtensionImpl = KeyManagerUtil
- .getOBKeyManagerExtensionImpl();
+ OBKeyManagerExtensionInterface obKeyManagerExtensionImpl = KeyManagerUtil.getOBKeyManagerExtensionImpl();
if (obKeyManagerExtensionImpl != null) {
obKeyManagerExtensionImpl.doPreCreateApplication(oAuthAppRequest, additionalProperties);
}
@@ -452,11 +421,8 @@ public void doPreCreateApplication(OAuthAppRequest oAuthAppRequest, HashMap additionalProperties,
- org.wso2.carbon.identity.application.common.model.ServiceProvider
- serviceProvider)
- throws APIManagementException {
- OBKeyManagerExtensionInterface obKeyManagerExtensionImpl = KeyManagerUtil
- .getOBKeyManagerExtensionImpl();
+ ServiceProvider serviceProvider) throws APIManagementException {
+ OBKeyManagerExtensionInterface obKeyManagerExtensionImpl = KeyManagerUtil.getOBKeyManagerExtensionImpl();
if (obKeyManagerExtensionImpl != null) {
obKeyManagerExtensionImpl.doPreUpdateApplication(oAuthAppRequest, additionalProperties, serviceProvider);
}
@@ -472,12 +438,11 @@ public void doPreUpdateApplication(OAuthAppRequest oAuthAppRequest, HashMap additionalProperties, boolean isCreateApp)
throws APIManagementException {
- OBKeyManagerExtensionInterface obKeyManagerExtensionImpl = KeyManagerUtil
- .getOBKeyManagerExtensionImpl();
+ OBKeyManagerExtensionInterface obKeyManagerExtensionImpl = KeyManagerUtil.getOBKeyManagerExtensionImpl();
if (obKeyManagerExtensionImpl != null) {
obKeyManagerExtensionImpl.doPreUpdateSpApp(oAuthConsumerAppDTO, serviceProvider, additionalProperties,
isCreateApp);
@@ -495,9 +460,8 @@ protected OAuthAdminService getOAuthAdminService() {
return new OAuthAdminService();
}
- protected org.wso2.carbon.identity.application.common.model.ServiceProviderProperty getSpPropertyFromSPMetaData(
- String propertyName,
- org.wso2.carbon.identity.application.common.model.ServiceProviderProperty[] spProperties) {
+ protected ServiceProviderProperty getSpPropertyFromSPMetaData(String propertyName,
+ ServiceProviderProperty[] spProperties) {
return Arrays.asList(spProperties).stream().filter(serviceProviderProperty -> serviceProviderProperty.getName()
.equalsIgnoreCase(propertyName)).findAny().orElse(null);
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/src/main/java/com/wso2/openbanking/accelerator/keymanager/internal/KeyManagerDataHolder.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/src/main/java/com/wso2/openbanking/accelerator/keymanager/internal/KeyManagerDataHolder.java
index 6e3b9060..0e35ac0e 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/src/main/java/com/wso2/openbanking/accelerator/keymanager/internal/KeyManagerDataHolder.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/src/main/java/com/wso2/openbanking/accelerator/keymanager/internal/KeyManagerDataHolder.java
@@ -22,7 +22,6 @@
import org.wso2.carbon.apimgt.impl.APIConstants;
import org.wso2.carbon.apimgt.impl.APIManagerConfigurationService;
import org.wso2.carbon.authenticator.stub.AuthenticationAdminStub;
-import org.wso2.carbon.identity.application.mgt.stub.IdentityApplicationManagementServiceStub;
import org.wso2.carbon.identity.oauth.stub.OAuthAdminServiceStub;
import org.wso2.carbon.user.core.service.RealmService;
import org.wso2.carbon.user.mgt.stub.UserAdminStub;
@@ -41,7 +40,6 @@ public class KeyManagerDataHolder {
public static final String AUTHENTICATION_ADMIN_SERVICE = "AuthenticationAdmin";
public static final String USER_ADMIN_SERVICE = "UserAdmin";
public static final String OAUTH_ADMIN_SERVICE = "OAuthAdminService";
- private IdentityApplicationManagementServiceStub identityApplicationManagementServiceStub;
private AuthenticationAdminStub authenticationAdminStub;
private OAuthAdminServiceStub oAuthAdminServiceStub;
private UserAdminStub userAdminStub;
@@ -75,23 +73,6 @@ public void setUserAdminStub(UserAdminStub userAdminStub) {
this.userAdminStub = userAdminStub;
}
- public IdentityApplicationManagementServiceStub getIdentityApplicationManagementServiceStub()
- throws AxisFault {
-
- if (identityApplicationManagementServiceStub == null) {
- String appMgtServiceURL = backendServerURL + IDENTITY_APPLICATION_MGT_SERVICE;
- identityApplicationManagementServiceStub = new IdentityApplicationManagementServiceStub(
- appMgtServiceURL);
- }
- return identityApplicationManagementServiceStub;
- }
-
- public void setIdentityApplicationManagementServiceStub(IdentityApplicationManagementServiceStub
- identityApplicationManagementServiceStub) {
-
- this.identityApplicationManagementServiceStub = identityApplicationManagementServiceStub;
- }
-
public AuthenticationAdminStub getAuthenticationAdminStub() throws AxisFault {
if (authenticationAdminStub == null) {
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/src/test/java/com/wso2/openbanking/accelerator/keymanager/KeyManagerTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/src/test/java/com/wso2/openbanking/accelerator/keymanager/KeyManagerTest.java
index a493ff2e..565e0d5b 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/src/test/java/com/wso2/openbanking/accelerator/keymanager/KeyManagerTest.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/src/test/java/com/wso2/openbanking/accelerator/keymanager/KeyManagerTest.java
@@ -52,11 +52,10 @@
import org.wso2.carbon.apimgt.impl.APIManagerConfigurationService;
import org.wso2.carbon.authenticator.stub.AuthenticationAdminStub;
import org.wso2.carbon.authenticator.stub.LoginAuthenticationExceptionException;
-import org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider;
-import org.wso2.carbon.identity.application.common.model.xsd.ServiceProviderProperty;
+import org.wso2.carbon.identity.application.common.IdentityApplicationManagementException;
+import org.wso2.carbon.identity.application.common.model.ServiceProvider;
+import org.wso2.carbon.identity.application.common.model.ServiceProviderProperty;
import org.wso2.carbon.identity.application.mgt.ApplicationManagementServiceImpl;
-import org.wso2.carbon.identity.application.mgt.stub.IdentityApplicationManagementServiceIdentityApplicationManagementException;
-import org.wso2.carbon.identity.application.mgt.stub.IdentityApplicationManagementServiceStub;
import org.wso2.carbon.identity.oauth.OAuthAdminService;
import org.wso2.carbon.identity.oauth.stub.OAuthAdminServiceIdentityOAuthAdminException;
import org.wso2.carbon.identity.oauth.stub.OAuthAdminServiceStub;
@@ -87,9 +86,6 @@ public class KeyManagerTest extends PowerMockTestCase {
@Mock
private OAuthAdminServiceStub oAuthAdminServiceStub;
- @Mock
- private IdentityApplicationManagementServiceStub identityApplicationManagementServiceStub;
-
@Mock
private AuthenticationAdminStub authenticationAdminStub;
@@ -174,9 +170,9 @@ public IObjectFactory getObjectFactory() {
@Test
public void testGetNewApplicationAccessToken() throws APIManagementException, RemoteException,
OAuthAdminServiceIdentityOAuthAdminException,
- IdentityApplicationManagementServiceIdentityApplicationManagementException,
- LoginAuthenticationExceptionException {
+ LoginAuthenticationExceptionException, IdentityApplicationManagementException {
+ OBKeyManagerImpl obKeyManager = spy(new OBKeyManagerImplMock());
OAuthConsumerAppDTO oAuthConsumerAppDTO = new OAuthConsumerAppDTO();
oAuthConsumerAppDTO.setApplicationName("AppName");
@@ -204,8 +200,6 @@ public void testGetNewApplicationAccessToken() throws APIManagementException, Re
KeyManagerDataHolder.getInstance().setApiManagerConfiguration(apiManagerConfigurationService);
KeyManagerDataHolder.getInstance().setAuthenticationAdminStub(authenticationAdminStub);
KeyManagerDataHolder.getInstance().setOauthAdminServiceStub(oAuthAdminServiceStub);
- KeyManagerDataHolder.getInstance()
- .setIdentityApplicationManagementServiceStub(identityApplicationManagementServiceStub);
AccessTokenRequest accessTokenRequest = new AccessTokenRequest();
@@ -227,16 +221,10 @@ public void testGetNewApplicationAccessToken() throws APIManagementException, Re
Mockito.when(oAuthAdminServiceStub.getOAuthApplicationData(anyString()))
.thenReturn(oAuthConsumerAppDTO);
- Mockito.when(keyManagerDataHolder.getIdentityApplicationManagementServiceStub())
- .thenReturn(identityApplicationManagementServiceStub);
-
- Mockito.when(identityApplicationManagementServiceStub._getServiceClient()).thenReturn(serviceClient);
- Mockito.when(identityApplicationManagementServiceStub
- .getApplication(oAuthConsumerAppDTO.getApplicationName()))
- .thenReturn(serviceProvider);
-
+ Mockito.when(obKeyManager.getApplicationMgmtServiceImpl()).thenReturn(applicationManagementServiceImpl);
+ Mockito.when(applicationManagementServiceImpl.getServiceProviderByClientId(
+ anyString(), anyString(), anyString())).thenReturn(serviceProvider);
AccessTokenInfo accessTokenInfo = obKeyManager.getNewApplicationAccessToken(accessTokenRequest);
-
Assert.assertTrue(accessTokenInfo == null);
}
@@ -249,7 +237,7 @@ public void testUpdateAdditionalProperties() {
keyManagerAdditionalProperties.put(dummyPropertyName2, property);
when(openBankingConfigParser.getKeyManagerAdditionalProperties()).thenReturn(keyManagerAdditionalProperties);
- spy(org.wso2.carbon.identity.application.common.model.ServiceProvider.class);
+ spy(ServiceProvider.class);
List spProperties =
new ArrayList<>();
@@ -305,8 +293,7 @@ public void testUpdateSpProperties() throws Exception {
spProperties[0] = (spProperty1);
spProperties[1] = (spProperty2);
- org.wso2.carbon.identity.application.common.model.ServiceProvider serviceProvider =
- spy(org.wso2.carbon.identity.application.common.model.ServiceProvider.class);
+ ServiceProvider serviceProvider = spy(ServiceProvider.class);
doNothing().when(applicationManagementServiceImpl).updateApplication(Mockito.anyObject(), Mockito.anyString(),
Mockito.anyString());
@@ -344,8 +331,7 @@ public void testUpdateSpProperties() throws Exception {
org.wso2.carbon.identity.oauth.dto.OAuthConsumerAppDTO oAuthConsumerAppDTOdummy =
new org.wso2.carbon.identity.oauth.dto.OAuthConsumerAppDTO();
- org.wso2.carbon.identity.application.common.model.ServiceProvider serviceProviderDummy =
- new org.wso2.carbon.identity.application.common.model.ServiceProvider();
+ ServiceProvider serviceProviderDummy = new ServiceProvider();
HashMap dummyMap = new HashMap<>();
doNothing().when(obKeyManager).doPreUpdateSpApp(oAuthConsumerAppDTOdummy, serviceProviderDummy, dummyMap,
@@ -460,7 +446,7 @@ public Object[][] validateOAuthAppCreationPropertiesDataProvider() {
@Test(dataProvider = "validateOAuthAppCreationPropertiesDataProvider",
description = "Validate user inputs for application creation")
public void testValidateOAuthAppCreationProperties(Map>
- keyManagerAdditionalProperties,
+ keyManagerAdditionalProperties,
List applicationConfigurationsList,
String valuesForProperties,
Class extends Exception> exceptionType) {
From a6d2b0b08ae6c5d316e4d4456d92a2f08d8c3226 Mon Sep 17 00:00:00 2001
From: kalpana
Date: Wed, 21 Feb 2024 14:23:17 +0530
Subject: [PATCH 060/281] Resolving the comments for the last update of
retrieval flow
---
.../common/util/ErrorConstants.java | 2 +
.../impl/DefaultConsentRetrievalStep.java | 5 +-
.../authorize/utils/ConsentRetrievalUtil.java | 490 +++++++++---------
.../impl/OBDefaultAuthServletImpl.java | 5 +-
4 files changed, 241 insertions(+), 261 deletions(-)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java
index 628dc98c..44d685af 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java
@@ -290,5 +290,7 @@ public class ErrorConstants {
public static final String PATH_PERIOD_TYPE = "Data.ControlParameters.PeriodicLimits.PeriodType";
public static final String PATH_PERIOD_ALIGNMENT = "Data.ControlParameters.PeriodicLimits.PeriodAlignment";
+ public static final String CONTROL_PARAMETERS_MISSING_ERROR = "Missing mandatory parameter the ControlParameters";
+ public static final String DATA_OBJECT_MISSING_ERROR = "Missing mandatory parameter the Data ";
}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/DefaultConsentRetrievalStep.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/DefaultConsentRetrievalStep.java
index f9b139f2..47950ff6 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/DefaultConsentRetrievalStep.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/DefaultConsentRetrievalStep.java
@@ -16,7 +16,6 @@
* under the License.
*/
-
package com.wso2.openbanking.accelerator.consent.extensions.authorize.impl;
import com.wso2.openbanking.accelerator.common.exception.ConsentManagementException;
@@ -120,9 +119,7 @@ public void execute(ConsentData consentData, JSONObject jsonObject) throws Conse
public JSONArray getConsentDataSet(ConsentResource consentResource)
throws ConsentException, ConsentManagementException, ParseException {
- JSONArray consent;
- consent = ConsentRetrievalUtil.getConsentData(consentResource);
- return consent;
+ return ConsentRetrievalUtil.getConsentData(consentResource);
}
}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/utils/ConsentRetrievalUtil.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/utils/ConsentRetrievalUtil.java
index 9827d708..93be7eb4 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/utils/ConsentRetrievalUtil.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/utils/ConsentRetrievalUtil.java
@@ -1,12 +1,12 @@
/**
- * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
- *
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
@@ -16,7 +16,6 @@
* under the License.
*/
-
package com.wso2.openbanking.accelerator.consent.extensions.authorize.utils;
@@ -146,51 +145,43 @@ public static boolean validateExpiryDateTime(String expiryDate) throws ConsentEx
}
}
-
/**
* Method to add debtor account details to consent data to send it to the consent page.
*
- * @param data Initiation object from the request
+ * @param initiation Initiation object from the request
* @param consentDataJSON Consent information object
*/
- public static void populateDebtorAccount(JSONObject data, JSONArray consentDataJSON) {
- if (consentDataJSON == null) {
- // Initialize consentDataJSON if it's null
- consentDataJSON = new JSONArray();
- }
+ public static void populateDebtorAccount(JSONObject initiation, JSONArray consentDataJSON) {
- if (data.containsKey(ConsentExtensionConstants.INITIATION)) {
- JSONObject initiation = (JSONObject) data.get(ConsentExtensionConstants.INITIATION);
-
- // Check if initiation contains the debtor account information
- if (initiation.containsKey(ConsentExtensionConstants.DEBTOR_ACC)) {
+ if (initiation.get(ConsentExtensionConstants.DEBTOR_ACC) != null) {
JSONObject debtorAccount = (JSONObject) initiation.get(ConsentExtensionConstants.DEBTOR_ACC);
JSONArray debtorAccountArray = new JSONArray();
- // Adding Debtor Account Scheme Name
- if (debtorAccount.containsKey(ConsentExtensionConstants.SCHEME_NAME)) {
+ //Adding Debtor Account Scheme Name
+ if (debtorAccount.getAsString(ConsentExtensionConstants.SCHEME_NAME) != null) {
debtorAccountArray.add(ConsentExtensionConstants.SCHEME_NAME_TITLE + " : " +
debtorAccount.getAsString(ConsentExtensionConstants.SCHEME_NAME));
}
- // Adding Debtor Account Identification
- if (debtorAccount.containsKey(ConsentExtensionConstants.IDENTIFICATION)) {
+ //Adding Debtor Account Identification
+ if (debtorAccount.getAsString(ConsentExtensionConstants.IDENTIFICATION) != null) {
debtorAccountArray.add(ConsentExtensionConstants.IDENTIFICATION_TITLE + " : " +
debtorAccount.getAsString(ConsentExtensionConstants.IDENTIFICATION));
}
- // Adding Debtor Account Name
- if (debtorAccount.containsKey(ConsentExtensionConstants.NAME)) {
+ //Adding Debtor Account Name
+ if (debtorAccount.getAsString(ConsentExtensionConstants.NAME) != null) {
debtorAccountArray.add(ConsentExtensionConstants.NAME_TITLE + " : " +
debtorAccount.getAsString(ConsentExtensionConstants.NAME));
}
- // Adding Debtor Account Secondary Identification
- if (debtorAccount.containsKey(ConsentExtensionConstants.SECONDARY_IDENTIFICATION)) {
+ //Adding Debtor Account Secondary Identification
+ if (debtorAccount.getAsString(ConsentExtensionConstants.SECONDARY_IDENTIFICATION) != null) {
debtorAccountArray.add(ConsentExtensionConstants.SECONDARY_IDENTIFICATION_TITLE + " : " +
debtorAccount.getAsString(ConsentExtensionConstants.SECONDARY_IDENTIFICATION));
}
+
JSONObject jsonElementDebtor = new JSONObject();
jsonElementDebtor.appendField(ConsentExtensionConstants.TITLE,
ConsentExtensionConstants.DEBTOR_ACC_TITLE);
@@ -198,56 +189,50 @@ public static void populateDebtorAccount(JSONObject data, JSONArray consentDataJ
consentDataJSON.add(jsonElementDebtor);
}
}
- }
+
/**
* Method to add debtor account details to consent data to send it to the consent page.
*
- * @param data
+ * @param initiation
* @param consentDataJSON
*/
- public static void populateCreditorAccount(JSONObject data, JSONArray consentDataJSON) {
-
- if (consentDataJSON == null) {
- consentDataJSON = new JSONArray();
- }
-
- if (data.containsKey(ConsentExtensionConstants.INITIATION)) {
- JSONObject initiation = (JSONObject) data.get(ConsentExtensionConstants.INITIATION);
-
- if (initiation.get(ConsentExtensionConstants.CREDITOR_ACC) != null) {
- JSONObject creditorAccount = (JSONObject) initiation.get(ConsentExtensionConstants.CREDITOR_ACC);
- JSONArray creditorAccountArray = new JSONArray();
- //Adding Debtor Account Scheme Name
- if (creditorAccount.getAsString(ConsentExtensionConstants.SCHEME_NAME) != null) {
- creditorAccountArray.add(ConsentExtensionConstants.SCHEME_NAME_TITLE + " : " +
- creditorAccount.getAsString(ConsentExtensionConstants.SCHEME_NAME));
- }
- //Adding Debtor Account Identification
- if (creditorAccount.getAsString(ConsentExtensionConstants.IDENTIFICATION) != null) {
- creditorAccountArray.add(ConsentExtensionConstants.IDENTIFICATION_TITLE + " : " +
- creditorAccount.getAsString(ConsentExtensionConstants.IDENTIFICATION));
- }
- //Adding Debtor Account Name
- if (creditorAccount.getAsString(ConsentExtensionConstants.NAME) != null) {
- creditorAccountArray.add(ConsentExtensionConstants.NAME_TITLE + " : " +
- creditorAccount.getAsString(ConsentExtensionConstants.NAME));
- }
- //Adding Debtor Account Secondary Identification
- if (creditorAccount.getAsString(ConsentExtensionConstants.SECONDARY_IDENTIFICATION) != null) {
- creditorAccountArray.add(ConsentExtensionConstants.SECONDARY_IDENTIFICATION_TITLE + " : " +
- creditorAccount.getAsString(ConsentExtensionConstants.SECONDARY_IDENTIFICATION));
- }
+ public static void populateCreditorAccount(JSONObject initiation, JSONArray consentDataJSON) {
- JSONObject jsonElementCreditor = new JSONObject();
- jsonElementCreditor.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.CREDITOR_ACC_TITLE);
- jsonElementCreditor.appendField(ConsentExtensionConstants.DATA_SIMPLE, creditorAccountArray);
- consentDataJSON.add(jsonElementCreditor);
+ if (initiation.get(ConsentExtensionConstants.CREDITOR_ACC) != null) {
+ JSONObject creditorAccount = (JSONObject) initiation.get(ConsentExtensionConstants.CREDITOR_ACC);
+ JSONArray creditorAccountArray = new JSONArray();
+ //Adding Debtor Account Scheme Name
+ if (creditorAccount.getAsString(ConsentExtensionConstants.SCHEME_NAME) != null) {
+ creditorAccountArray.add(ConsentExtensionConstants.SCHEME_NAME_TITLE + " : " +
+ creditorAccount.getAsString(ConsentExtensionConstants.SCHEME_NAME));
+ }
+ //Adding Debtor Account Identification
+ if (creditorAccount.getAsString(ConsentExtensionConstants.IDENTIFICATION) != null) {
+ creditorAccountArray.add(ConsentExtensionConstants.IDENTIFICATION_TITLE + " : " +
+ creditorAccount.getAsString(ConsentExtensionConstants.IDENTIFICATION));
+ }
+ //Adding Debtor Account Name
+ if (creditorAccount.getAsString(ConsentExtensionConstants.NAME) != null) {
+ creditorAccountArray.add(ConsentExtensionConstants.NAME_TITLE + " : " +
+ creditorAccount.getAsString(ConsentExtensionConstants.NAME));
}
+ //Adding Debtor Account Secondary Identification
+ if (creditorAccount.getAsString(ConsentExtensionConstants.SECONDARY_IDENTIFICATION) != null) {
+ creditorAccountArray.add(ConsentExtensionConstants.SECONDARY_IDENTIFICATION_TITLE + " : " +
+ creditorAccount.getAsString(ConsentExtensionConstants.SECONDARY_IDENTIFICATION));
+ }
+
+ JSONObject jsonElementCreditor = new JSONObject();
+ jsonElementCreditor.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.CREDITOR_ACC_TITLE);
+ jsonElementCreditor.appendField(ConsentExtensionConstants.DATA_SIMPLE, creditorAccountArray);
+ consentDataJSON.add(jsonElementCreditor);
}
}
+
+
/**
* Method to append Dummy data for Account ID. Ideally should be separate step calling accounts service
*
@@ -279,82 +264,82 @@ public static JSONArray appendDummyAccountID() {
* @param consentResource Consent Resource parameter containing consent related information retrieved from database
* @return ConsentDataJson array
*/
- public static JSONArray getConsentData(ConsentResource consentResource) throws ParseException {
-
- JSONArray consentDataJSON = getConsentRetrievalDataSet(consentResource);
- String receiptString = consentResource.getReceipt();
- Object receiptJSON = new JSONParser(JSONParser.MODE_PERMISSIVE).parse(receiptString);
-
- JSONObject receipt = (JSONObject) receiptJSON;
- JSONObject data = (JSONObject) receipt.get(ConsentExtensionConstants.DATA);
- JSONObject controlParameters = (JSONObject) data.get(ConsentExtensionConstants.CONTROL_PARAMETERS);
-
-
- String type = consentResource.getConsentType();
- switch (type) {
- case ConsentExtensionConstants.ACCOUNTS:
- consentDataJSON = populateAccountData(data, consentDataJSON);
- break;
- case ConsentExtensionConstants.PAYMENTS:
- consentDataJSON = populateSinglePaymentData(data, consentDataJSON);
- // Adding Debtor Account
- ConsentRetrievalUtil.populateDebtorAccount(data, consentDataJSON);
- // Adding Creditor Account
- ConsentRetrievalUtil.populateCreditorAccount(data, consentDataJSON);
- break;
- case ConsentExtensionConstants.FUNDSCONFIRMATIONS:
- consentDataJSON = populateCofData(data, consentDataJSON);
- break;
- case ConsentExtensionConstants.VRP:
- consentDataJSON = populateVRData(controlParameters, consentDataJSON);
- break;
- default:
- break;
- }
- return consentDataJSON;
-
- }
-
- /**
- * Method defined to retrieve the Payment consent related data in the authorization flow to send them to the
- * consent page to get PSU consent.
- *
- * @param consentResource Consent Resource parameter containing consent related information retrieved from database
- */
- public static JSONArray getConsentRetrievalDataSet(ConsentResource consentResource) {
+ public static JSONArray getConsentData(ConsentResource consentResource) {
+ JSONArray consentDataJSON;
try {
+ consentDataJSON = new JSONArray();
String receiptString = consentResource.getReceipt();
Object receiptJSON = new JSONParser(JSONParser.MODE_PERMISSIVE).parse(receiptString);
- //Checking whether the request body is in JSON format
+ // Checking whether the request body is in JSON format
if (!(receiptJSON instanceof JSONObject)) {
log.error(ErrorConstants.NOT_JSON_OBJECT_ERROR);
throw new ConsentException(ResponseStatus.INTERNAL_SERVER_ERROR, ErrorConstants.NOT_JSON_OBJECT_ERROR);
}
- //Checking whether the consent status is valid
+ // Checking whether the consent status is valid
if (!consentResource.getCurrentStatus().equals(ConsentExtensionConstants.AWAITING_AUTH_STATUS)) {
log.error(ErrorConstants.STATE_INVALID_ERROR);
- //Currently throwing error as 400 response. Developer also have the option of appending a field IS_ERROR
- // to the jsonObject and showing it to the user in the webapp. If so, the IS_ERROR have to be checked in
- // any later steps.
+ // Currently throwing an error as a 400 response.
+ // Developers have the option of appending a field IS_ERROR to the jsonObject
+ // and showing it to the user in the webapp. If so, the IS_ERROR has to be checked in any later steps.
throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.STATE_INVALID_ERROR);
}
+
+ JSONObject receipt = (JSONObject) receiptJSON;
+
+ // Checks if 'data' object is present in the receipt
+ if (receipt.containsKey(ConsentExtensionConstants.DATA)) {
+ JSONObject data = (JSONObject) receipt.get(ConsentExtensionConstants.DATA);
+
+ String type = consentResource.getConsentType();
+ switch (type) {
+ case ConsentExtensionConstants.ACCOUNTS:
+ consentDataJSON = populateAccountData(data, consentDataJSON);
+ break;
+ case ConsentExtensionConstants.PAYMENTS:
+ consentDataJSON = populatePaymentData(data, consentDataJSON);
+ break;
+ case ConsentExtensionConstants.FUNDSCONFIRMATIONS:
+ consentDataJSON = populateCofData(data, consentDataJSON);
+ break;
+ case ConsentExtensionConstants.VRP:
+ // Check if 'controlParameters' object is present in the 'data'
+ if (data.containsKey(ConsentExtensionConstants.CONTROL_PARAMETERS)) {
+ JSONObject controlParameters = (JSONObject) data.
+ get(ConsentExtensionConstants.CONTROL_PARAMETERS);
+
+ populateVRPData(controlParameters, consentDataJSON);
+ } else {
+ log.error(ErrorConstants.CONTROL_PARAMETERS_MISSING_ERROR);
+ throw new ConsentException(ResponseStatus.BAD_REQUEST,
+ ErrorConstants.CONTROL_PARAMETERS_MISSING_ERROR);
+ }
+ break;
+ default:
+ break;
+ }
+ } else {
+ log.error(ErrorConstants.DATA_OBJECT_MISSING_ERROR);
+ throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.DATA_OBJECT_MISSING_ERROR);
+ }
+
} catch (ParseException e) {
throw new ConsentException(ResponseStatus.INTERNAL_SERVER_ERROR, ErrorConstants.CONSENT_RETRIEVAL_ERROR);
}
- return null;
+ return consentDataJSON;
}
+
/**
* Populate Domestic and international Payment Details.
*
- * @param data data request from the request
- * @param consentDataJSON Consent information
+ * @param data data request from the request
+ * @param consentDataJSON Consent information
*/
- private static JSONArray populateSinglePaymentData(JSONObject data, JSONArray consentDataJSON) {
+ private static JSONArray populatePaymentData(JSONObject data, JSONArray consentDataJSON) {
if (consentDataJSON == null) {
// Initialize consentDataJSON if it's null
@@ -438,8 +423,13 @@ private static JSONArray populateSinglePaymentData(JSONObject data, JSONArray co
ConsentExtensionConstants.INSTRUCTED_AMOUNT_TITLE);
jsonElementInstructedAmount.appendField(ConsentExtensionConstants.DATA_SIMPLE, instructedAmountArray);
consentDataJSON.add(jsonElementInstructedAmount);
- }
+ // Adding Debtor Account
+ populateDebtorAccount(initiation, consentDataJSON);
+ // Adding Creditor Account
+ populateCreditorAccount(initiation, consentDataJSON);
+
+ }
return consentDataJSON;
}
@@ -447,8 +437,8 @@ private static JSONArray populateSinglePaymentData(JSONObject data, JSONArray co
/**
* Populate account Details.
*
- * @param data data request from the request
- * @param consentDataJSON Consent information
+ * @param data data request from the request
+ * @param consentDataJSON Consent information
*/
private static JSONArray populateAccountData(JSONObject data, JSONArray consentDataJSON) {
@@ -516,78 +506,51 @@ private static JSONArray populateAccountData(JSONObject data, JSONArray consentD
/**
* Populate funds confirmation Details.
*
- * @param data data request from the request
- * @param consentDataJSON Consent information
+ * @param initiation data from the request
+ * @param consentDataJSON Consent information
*/
- private static JSONArray populateCofData(JSONObject data, JSONArray consentDataJSON) {
+ private static JSONArray populateCofData(JSONObject initiation, JSONArray consentDataJSON) {
if (consentDataJSON == null) {
consentDataJSON = new JSONArray();
}
- //Adding Expiration Date Time
- if (data.getAsString(ConsentExtensionConstants.EXPIRATION_DATE) != null) {
+ //Adding Expiration Date Time
+ if (initiation.getAsString(ConsentExtensionConstants.EXPIRATION_DATE) != null) {
- if (!ConsentRetrievalUtil
- .validateExpiryDateTime(data.getAsString(ConsentExtensionConstants.EXPIRATION_DATE))) {
- log.error(ErrorConstants.CONSENT_EXPIRED);
- throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.CONSENT_EXPIRED);
- }
+ if (!ConsentRetrievalUtil
+ .validateExpiryDateTime(initiation.getAsString(ConsentExtensionConstants.EXPIRATION_DATE))) {
+ log.error(ErrorConstants.CONSENT_EXPIRED);
+ throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.CONSENT_EXPIRED);
+ }
- String expiry = data.getAsString(ConsentExtensionConstants.EXPIRATION_DATE);
- JSONArray expiryArray = new JSONArray();
- expiryArray.add(expiry);
+ String expiry = initiation.getAsString(ConsentExtensionConstants.EXPIRATION_DATE);
+ JSONArray expiryArray = new JSONArray();
+ expiryArray.add(expiry);
- JSONObject jsonElementExpiry = new JSONObject();
- jsonElementExpiry.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.EXPIRATION_DATE_TITLE);
- jsonElementExpiry.appendField(ConsentExtensionConstants.DATA_SIMPLE, expiryArray);
- consentDataJSON.add(jsonElementExpiry);
- } else {
- JSONArray expiryArray = new JSONArray();
- expiryArray.add(ConsentExtensionConstants.OPEN_ENDED_AUTHORIZATION);
+ JSONObject jsonElementExpiry = new JSONObject();
+ jsonElementExpiry.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.EXPIRATION_DATE_TITLE);
+ jsonElementExpiry.appendField(ConsentExtensionConstants.DATA_SIMPLE, expiryArray);
+ consentDataJSON.add(jsonElementExpiry);
+ } else {
+ JSONArray expiryArray = new JSONArray();
+ expiryArray.add(ConsentExtensionConstants.OPEN_ENDED_AUTHORIZATION);
- JSONObject jsonElementExpiry = new JSONObject();
- jsonElementExpiry.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.EXPIRATION_DATE_TITLE);
- jsonElementExpiry.appendField(ConsentExtensionConstants.DATA_SIMPLE, expiryArray);
- consentDataJSON.add(jsonElementExpiry);
- }
+ JSONObject jsonElementExpiry = new JSONObject();
+ jsonElementExpiry.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.EXPIRATION_DATE_TITLE);
+ jsonElementExpiry.appendField(ConsentExtensionConstants.DATA_SIMPLE, expiryArray);
+ consentDataJSON.add(jsonElementExpiry);
- //Adding Debtor Account
- if (data.get(ConsentExtensionConstants.DEBTOR_ACC) != null) {
- JSONObject debtorAccount = (JSONObject) data.get(ConsentExtensionConstants.DEBTOR_ACC);
- JSONArray debtorAccountArray = new JSONArray();
- //Adding Debtor Account Scheme Name
- if (debtorAccount.getAsString(ConsentExtensionConstants.SCHEME_NAME) != null) {
- debtorAccountArray.add(ConsentExtensionConstants.SCHEME_NAME_TITLE + " : " +
- debtorAccount.getAsString(ConsentExtensionConstants.SCHEME_NAME));
- }
- //Adding Debtor Account Identification
- if (debtorAccount.getAsString(ConsentExtensionConstants.IDENTIFICATION) != null) {
- debtorAccountArray.add(ConsentExtensionConstants.IDENTIFICATION_TITLE + " : " +
- debtorAccount.getAsString(ConsentExtensionConstants.IDENTIFICATION));
- }
- //Adding Debtor Account Name
- if (debtorAccount.getAsString(ConsentExtensionConstants.NAME) != null) {
- debtorAccountArray.add(ConsentExtensionConstants.NAME_TITLE + " : " +
- debtorAccount.getAsString(ConsentExtensionConstants.NAME));
- }
- //Adding Debtor Account Secondary Identification
- if (debtorAccount.getAsString(ConsentExtensionConstants.SECONDARY_IDENTIFICATION) != null) {
- debtorAccountArray.add(ConsentExtensionConstants.SECONDARY_IDENTIFICATION_TITLE + " : " +
- debtorAccount.getAsString(ConsentExtensionConstants.SECONDARY_IDENTIFICATION));
}
- JSONObject jsonElementDebtor = new JSONObject();
- jsonElementDebtor.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.DEBTOR_ACC_TITLE);
- jsonElementDebtor.appendField(ConsentExtensionConstants.DATA_SIMPLE, debtorAccountArray);
- consentDataJSON.add(jsonElementDebtor);
+ if (initiation.get(ConsentExtensionConstants.DEBTOR_ACC) != null) {
+ //Adding Debtor Account
+ populateDebtorAccount(initiation, consentDataJSON);
}
return consentDataJSON;
-
}
@@ -597,7 +560,7 @@ private static JSONArray populateCofData(JSONObject data, JSONArray consentDataJ
* @param controlParameters Control Parameters from the request
* @param consentDataJSON Consent information object
*/
- private static JSONArray populateVRData(JSONObject controlParameters, JSONArray consentDataJSON) {
+ private static JSONArray populateVRPData(JSONObject controlParameters, JSONArray consentDataJSON) {
if (consentDataJSON == null) {
consentDataJSON = new JSONArray();
@@ -613,85 +576,104 @@ private static JSONArray populateVRData(JSONObject controlParameters, JSONArray
jsonElementPaymentType.appendField(ConsentExtensionConstants.DATA_SIMPLE, paymentTypeArray);
consentDataJSON.add(jsonElementPaymentType);
- // Constructing jsonElementValidToDataTime
- JSONObject jsonElementValidToDateTime = new JSONObject();
- jsonElementValidToDateTime.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.CONTROL_PARAMETER_VALID_TO_DATE_TITLE);
- JSONArray dateControlParameterArray = new JSONArray();
- dateControlParameterArray.add((controlParameters).
- get(ConsentExtensionConstants.VALID_TO_DATE_TIME));
- jsonElementValidToDateTime.appendField(ConsentExtensionConstants.DATA_SIMPLE, dateControlParameterArray);
-
- // Constructing jsonElementValidFromDataTime
- JSONObject jsonElementValidFromDateTime = new JSONObject();
- jsonElementValidFromDateTime.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.CONTROL_PARAMETER_VALID_FROM_DATE_TITLE);
- JSONArray dateTimeControlParameterArray = new JSONArray();
- dateTimeControlParameterArray.add((controlParameters).
- get(ConsentExtensionConstants.VALID_FROM_DATE_TIME));
- jsonElementValidFromDateTime.appendField(ConsentExtensionConstants.DATA_SIMPLE, dateTimeControlParameterArray);
-
- // Constructing jsonElementControlParameter
- JSONObject jsonElementControlParameter = new JSONObject();
- jsonElementControlParameter.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.CONTROL_PARAMETER_MAX_INDIVIDUAL_AMOUNT_TITLE);
- JSONArray controlParameterArray = new JSONArray();
-
- String formattedAmount = String.format("%s %s",
- ((JSONObject) controlParameters.get(ConsentExtensionConstants.MAXIMUM_INDIVIDUAL_AMOUNT))
- .get(ConsentExtensionConstants.CURRENCY),
- ((JSONObject) controlParameters.get(ConsentExtensionConstants.MAXIMUM_INDIVIDUAL_AMOUNT))
- .get(ConsentExtensionConstants.AMOUNT));
- controlParameterArray.add(formattedAmount);
- jsonElementControlParameter.appendField(ConsentExtensionConstants.DATA_SIMPLE, controlParameterArray);
-
- // Constructing jsonElementPeriodAlignment
- JSONObject jsonElementPeriodAlignment = new JSONObject();
- jsonElementPeriodAlignment.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.CONTROL_PARAMETER_PERIOD_ALIGNMENT_TITLE);
- String periodAlignment = (String) ((JSONObject) ((JSONArray) controlParameters
- .get(ConsentExtensionConstants.PERIODIC_LIMITS)).get(0))
- .get(ConsentExtensionConstants.PERIOD_ALIGNMENT);
- JSONArray periodAlignmentArray = new JSONArray();
- periodAlignmentArray.add(periodAlignment);
- jsonElementPeriodAlignment.appendField(ConsentExtensionConstants.DATA_SIMPLE, periodAlignmentArray);
-
- // Constructing jsonElementPeriodType
- JSONObject jsonElementPeriodType = new JSONObject();
- jsonElementPeriodType.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.CONTROL_PARAMETER_PERIOD_TYPE_TITLE);
- String periodType = (String) ((JSONObject) ((JSONArray) controlParameters
- .get(ConsentExtensionConstants.PERIODIC_LIMITS)).get(0)).get(ConsentExtensionConstants.PERIOD_TYPE);
- JSONArray periodTypeArray = new JSONArray();
- periodTypeArray.add(periodType);
- jsonElementPeriodType.appendField(ConsentExtensionConstants.DATA_SIMPLE, periodTypeArray);
-
- // Constructing jsonElementPeriodicLimits
- JSONObject jsonElementPeriodicLimits = new JSONObject();
- jsonElementPeriodicLimits.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.CONTROL_PARAMETER_AMOUNT_TITLE + periodType);
- JSONArray periodicLimitsArray = new JSONArray();
-
- JSONObject periodicLimitsObject = (JSONObject) ((JSONArray) controlParameters
- .get(ConsentExtensionConstants.PERIODIC_LIMITS)).get(0);
-
- String currency = (String) periodicLimitsObject.get(ConsentExtensionConstants.CURRENCY);
- String amount = (String) periodicLimitsObject.get(ConsentExtensionConstants.AMOUNT);
-
- // Concatenate currency and amount in the desired order
- String formattedPeriodicAmount = String.format("%s %s", currency, amount);
-
- periodicLimitsArray.add(formattedPeriodicAmount);
-
- jsonElementPeriodicLimits.appendField(ConsentExtensionConstants.DATA_SIMPLE, periodicLimitsArray);
-
- // Adding constructed JSON objects to consentDataJSON
- consentDataJSON.add(jsonElementControlParameter);
- consentDataJSON.add(jsonElementPeriodAlignment);
- consentDataJSON.add(jsonElementPeriodicLimits);
- consentDataJSON.add(jsonElementPeriodType);
- consentDataJSON.add(jsonElementValidToDateTime);
- consentDataJSON.add(jsonElementValidFromDateTime);
+ String expirationDate = controlParameters.getAsString(ConsentExtensionConstants.VALID_FROM_DATE_TIME);
+ if (expirationDate != null) {
+ // Constructing jsonElementValidToDataTime
+ JSONObject jsonElementValidToDateTime = new JSONObject();
+ jsonElementValidToDateTime.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.CONTROL_PARAMETER_VALID_TO_DATE_TITLE);
+ JSONArray dateControlParameterArray = new JSONArray();
+ dateControlParameterArray.add((controlParameters).
+ get(ConsentExtensionConstants.VALID_TO_DATE_TIME));
+ jsonElementValidToDateTime.appendField(ConsentExtensionConstants.DATA_SIMPLE, dateControlParameterArray);
+
+ consentDataJSON.add(jsonElementValidToDateTime);
+ }
+
+ String expirationDates = controlParameters.getAsString(ConsentExtensionConstants.VALID_TO_DATE_TIME);
+ if (expirationDates != null) {
+ // Constructing jsonElementValidFromDataTime
+ JSONObject jsonElementValidFromDateTime = new JSONObject();
+ jsonElementValidFromDateTime.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.CONTROL_PARAMETER_VALID_FROM_DATE_TITLE);
+ JSONArray dateTimeControlParameterArray = new JSONArray();
+ dateTimeControlParameterArray.add((controlParameters).
+ get(ConsentExtensionConstants.VALID_FROM_DATE_TIME));
+ jsonElementValidFromDateTime.appendField(ConsentExtensionConstants.DATA_SIMPLE,
+ dateTimeControlParameterArray);
+ consentDataJSON.add(jsonElementValidFromDateTime);
+ }
+
+ String maxAmount = controlParameters.getAsString(ConsentExtensionConstants.MAXIMUM_INDIVIDUAL_AMOUNT);
+ if (maxAmount != null) {
+ // Constructing jsonElementControlParameter
+ JSONObject jsonElementControlParameter = new JSONObject();
+ jsonElementControlParameter.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.CONTROL_PARAMETER_MAX_INDIVIDUAL_AMOUNT_TITLE);
+ JSONArray controlParameterArray = new JSONArray();
+
+
+ JSONObject maximumIndividualAmount = ((JSONObject) controlParameters.
+ get(ConsentExtensionConstants.MAXIMUM_INDIVIDUAL_AMOUNT));
+
+ String formattedAmount = String.format("%s %s",
+ (maximumIndividualAmount.get(ConsentExtensionConstants.CURRENCY)),
+ (maximumIndividualAmount.get(ConsentExtensionConstants.AMOUNT)));
+ controlParameterArray.add(formattedAmount);
+ jsonElementControlParameter.appendField(ConsentExtensionConstants.DATA_SIMPLE, controlParameterArray);
+
+ consentDataJSON.add(jsonElementControlParameter);
+ }
+
+ // Constructing jsonElementPeriodAlignment
+ JSONObject jsonElementPeriodAlignment = new JSONObject();
+ jsonElementPeriodAlignment.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.CONTROL_PARAMETER_PERIOD_ALIGNMENT_TITLE);
+ String periodAlignment = (String) ((JSONObject) ((JSONArray) controlParameters
+ .get(ConsentExtensionConstants.PERIODIC_LIMITS)).get(0))
+ .get(ConsentExtensionConstants.PERIOD_ALIGNMENT);
+
+ if (periodAlignment != null) {
+ JSONArray periodAlignmentArray = new JSONArray();
+ periodAlignmentArray.add(periodAlignment);
+ jsonElementPeriodAlignment.appendField(ConsentExtensionConstants.DATA_SIMPLE, periodAlignmentArray);
+ consentDataJSON.add(jsonElementPeriodAlignment);
+ }
+
+ // Constructing jsonElementPeriodType
+ JSONObject jsonElementPeriodType = new JSONObject();
+ jsonElementPeriodType.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.CONTROL_PARAMETER_PERIOD_TYPE_TITLE);
+ String periodType = (String) ((JSONObject) ((JSONArray) controlParameters
+ .get(ConsentExtensionConstants.PERIODIC_LIMITS)).get(0)).get(ConsentExtensionConstants.PERIOD_TYPE);
+
+ if (periodType != null) {
+ JSONArray periodTypeArray = new JSONArray();
+ periodTypeArray.add(periodType);
+ jsonElementPeriodType.appendField(ConsentExtensionConstants.DATA_SIMPLE, periodTypeArray);
+ consentDataJSON.add(jsonElementPeriodType);
+ }
+
+ // Constructing jsonElementPeriodicLimits
+ JSONObject jsonElementPeriodicLimits = new JSONObject();
+ jsonElementPeriodicLimits.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.CONTROL_PARAMETER_AMOUNT_TITLE + periodType);
+ JSONArray periodicLimitsArray = new JSONArray();
+
+ JSONObject periodicLimitsObject = (JSONObject) ((JSONArray) controlParameters
+ .get(ConsentExtensionConstants.PERIODIC_LIMITS)).get(0);
+
+ if (periodicLimitsObject != null) {
+ String currency = (String) periodicLimitsObject.get(ConsentExtensionConstants.CURRENCY);
+ String amount = (String) periodicLimitsObject.get(ConsentExtensionConstants.AMOUNT);
+ String formattedPeriodicAmount = String.format("%s %s", currency, amount);
+
+ periodicLimitsArray.add(formattedPeriodicAmount);
+
+ jsonElementPeriodicLimits.appendField(ConsentExtensionConstants.DATA_SIMPLE, periodicLimitsArray);
+ consentDataJSON.add(jsonElementPeriodicLimits);
+
+ }
return consentDataJSON;
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authservlet/impl/OBDefaultAuthServletImpl.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authservlet/impl/OBDefaultAuthServletImpl.java
index 77aea95b..42838db2 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authservlet/impl/OBDefaultAuthServletImpl.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authservlet/impl/OBDefaultAuthServletImpl.java
@@ -91,9 +91,8 @@ public Map updateConsentMetaData(HttpServletRequest request) {
@Override
public String getJSPPath() {
- if (jspPath.equalsIgnoreCase(ConsentExtensionConstants.ACCOUNTS)) {
- return "/ob_default.jsp";
- } else if (jspPath.equalsIgnoreCase(ConsentExtensionConstants.VRP)) {
+ if (jspPath.equalsIgnoreCase(ConsentExtensionConstants.ACCOUNTS) ||
+ jspPath.equalsIgnoreCase(ConsentExtensionConstants.VRP)) {
return "/ob_default.jsp";
} else {
return "/default_displayconsent.jsp";
From cf5221f859e25f6f558d7a1c891277b6ef9587ee Mon Sep 17 00:00:00 2001
From: kalpana
Date: Wed, 21 Feb 2024 14:31:43 +0530
Subject: [PATCH 061/281] Unit test for VRP Retrieval Flow
---
.../flow/ConsentAuthorizeTestConstants.java | 322 +++++++++++++++
.../flow/ConsentExtensionDataProvider.java | 17 +
.../flow/VRPConsentRetrievalStepTest.java | 291 +++++++++++++
.../flow/VRPConsentRetrievalUtilTest.java | 389 ++++++++++++++++++
.../src/test/resources/testng.xml | 1 +
5 files changed, 1020 insertions(+)
create mode 100644 open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/ConsentAuthorizeTestConstants.java
create mode 100644 open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/ConsentExtensionDataProvider.java
create mode 100644 open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/VRPConsentRetrievalStepTest.java
create mode 100644 open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/VRPConsentRetrievalUtilTest.java
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/ConsentAuthorizeTestConstants.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/ConsentAuthorizeTestConstants.java
new file mode 100644
index 00000000..eeebf157
--- /dev/null
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/ConsentAuthorizeTestConstants.java
@@ -0,0 +1,322 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.openbanking.accelerator.consent.extensions.authorize.vrp.retrieval.flow;
+
+import java.time.Instant;
+import java.time.OffsetDateTime;
+
+/**
+ * Constant class for consent authorize tests.
+ */
+public class ConsentAuthorizeTestConstants {
+ public static final String INVALID_REQUEST_OBJECT = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.aWF0.TIygRaBn7MUFR9Zzy3" +
+ "yu9K8uKVe8KXdAty0Ckrg2vFI";
+ public static final String VALID_REQUEST_OBJECT = "eyJhbGciOiJQUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IkR3TUtkV01tajdQV2" +
+ "ludm9xZlF5WFZ6eVo2USJ9.eyJtYXhfYWdlIjo4NjQwMCwiYXVkIjoiaHR0cHM6Ly9sb2NhbGhvc3Q6OTQ0Ni9vYXV0aDIvdG9rZW4iL" +
+ "CJzY29wZSI6Im9wZW5pZCBhY2NvdW50cyIsImlzcyI6InF3ZGZnaGpwbG1nZmRhYWhrZ2pvcGhuayIsImNsYWltcyI6eyJpZF90b2tlb" +
+ "iI6eyJhY3IiOnsidmFsdWVzIjpbInVybjpvcGVuYmFua2luZzpwc2QyOnNjYSIsInVybjpvcGVuYmFua2luZzpwc2QyOmNhIl0sImVzc" +
+ "2VudGlhbCI6dHJ1ZX0sIm9wZW5iYW5raW5nX2ludGVudF9pZCI6eyJ2YWx1ZSI6IjEyMzQ1Njc3NjU0MzIxMjM0MjM0IiwiZXNzZW50a" +
+ "WFsIjp0cnVlfX0sInVzZXJpbmZvIjp7Im9wZW5iYW5raW5nX2ludGVudF9pZCI6eyJ2YWx1ZSI6IjEyMzQ1Njc3NjU0MzIxMjM0MjM0I" +
+ "iwiZXNzZW50aWFsIjp0cnVlfX19LCJyZXNwb25zZV90eXBlIjoiY29kZSBpZF90b2tlbiIsInJlZGlyZWN0X3VyaSI6Imh0dHBzOi8vd" +
+ "3NvMi5jb20iLCJzdGF0ZSI6IllXbHpjRG96TVRRMiIsImV4cCI6MTY1MzcxNzQ3OCwibm9uY2UiOiJuLTBTNl9XekEyTSIsImNsaWVud" +
+ "F9pZCI6InF3ZGZnaGpwbG1nZmRhYWhrZ2pvcGhuayJ9.lOvcc81dqjqdv4dslB_Kg4K3TKd13UQWaUKl3dBiPPlnu9y-R84Xfx-bMMnH" +
+ "atYyW9hYWJcUlprIm_dqgFXauCSTgBz6-vacrXLzuaGtj07d-8bL_qta45qbpbKPTY2pnM_PXe7fzs4RMCGEoiRLRs7lJUBfIbV9GzlS" +
+ "pHkOZiOjiFxxeYm0cNpZRvXkZNd59_GLdW2kKmWaGQHpQ9Ci_QpQENRzF8KEV1QtNd3cK2DjL5tKSw824C6AmXp-PKfvhurqPaVkz5p-" +
+ "iPA6bRaNBPY4hj_nsZpfuCnE8-V7YXWXXzWbK3gWo_dMOV1CZcHS6KqP7DANqDEEP4LoN081uQ";
+
+ public static final OffsetDateTime EXP_DATE = OffsetDateTime.now().plusDays(50);
+
+ public static final OffsetDateTime INVALID_EXP_DATE = OffsetDateTime.now().plusDays(0);
+
+ public static final OffsetDateTime NULL_EXP_DATE = null;
+ public static final String VALID_INITIATION_OBJECT = "{\"Data\": {\"Permissions\": [\"ReadAccountsDetail\"," +
+ "\"ReadBalances\",\"ReadBeneficiariesDetail\",\"ReadDirectDebits\",\"ReadProducts\"," +
+ "\"ReadStandingOrdersDetail\",\"ReadTransactionsCredits\",\"ReadTransactionsDebits\"," +
+ "\"ReadTransactionsDetail\",\"ReadOffers\",\"ReadPAN\",\"ReadParty\",\"ReadPartyPSU\"," +
+ " \"ReadScheduledPaymentsDetail\",\"ReadStatementsDetail\"],\"ExpirationDateTime\": " +
+ "\"" + EXP_DATE + "\",\"TransactionFromDateTime\": \"2021-05-03T00:00:00+00:00\"," +
+ "\"TransactionToDateTime\": \"2021-12-03T00:00:00+00:00\"},\"Risk\": {}}";
+
+ public static final String INVALID_INITIATION_OBJECT = "{\"Data\": {\"Permissions\": [\"ReadAccountsDetail\"," +
+ "\"ReadBalances\",\"ReadBeneficiariesDetail\",\"ReadDirectDebits\",\"ReadProducts\"," +
+ "\"ReadStandingOrdersDetail\",\"ReadTransactionsCredits\",\"ReadTransactionsDebits\"," +
+ "\"ReadTransactionsDetail\",\"ReadOffers\",\"ReadPAN\",\"ReadParty\",\"ReadPartyPSU\"," +
+ " \"ReadScheduledPaymentsDetail\",\"ReadStatementsDetail\"],\"ExpirationDateTime\": " +
+ "\"" + INVALID_EXP_DATE + "\",\"TransactionFromDateTime\": \"2021-05-03T00:00:00+00:00\"," +
+ "\"TransactionToDateTime\": \"2021-12-03T00:00:00+00:00\"},\"Risk\": {}}";
+
+
+ public static final String AWAITING_AUTH_STATUS = "awaitingAuthorisation";
+
+ public static final long CREATED_TIME = Instant.now().toEpochMilli();
+ public static final String COF_RECEIPT = "{" +
+ " \"Data\": {" +
+ " \"DebtorAccount\": {" +
+ " \"SchemeName\": \"OB.IBAN\"," +
+ " \"Identification\": \"GB76LOYD30949301273801\"," +
+ " \"Name\": \"Andrea Smith\"," +
+ " \"SecondaryIdentification\": \"Roll 56988\"" +
+ " }," +
+ " \"ExpirationDateTime\": \"" + EXP_DATE + "\"" +
+ " }" +
+ "}";
+
+ public static final String INVALID_COF_RECEIPT = "{" +
+ " \"Data\": {" +
+ " \"DebtorAccount\": {" +
+ " \"SchemeName\": \"OB.IBAN\"," +
+ " \"Identification\": \"GB76LOYD30949301273801\"," +
+ " \"Name\": \"Andrea Smith\"," +
+ " \"SecondaryIdentification\": \"Roll 56988\"" +
+ " }," +
+ " \"ExpirationDateTime\": \"" + INVALID_EXP_DATE + "\"" +
+ " }" +
+ "}";
+
+ public static final String NULL_COF_RECEIPT = "{" +
+ " \"Data\": {" +
+ " \"DebtorAccount\": {" +
+ " \"SchemeName\": \"OB.IBAN\"," +
+ " \"Identification\": \"GB76LOYD30949301273801\"," +
+ " \"Name\": \"Andrea Smith\"," +
+ " \"SecondaryIdentification\": \"Roll 56988\"" +
+ " }," +
+ " \"ExpirationDateTime\": \"" + NULL_EXP_DATE + "\"" +
+ " }" +
+ "}";
+ public static final String VRP_INITIATION = "{\n" +
+ " \"Data\": {\n" +
+ " \"ReadRefundAccount\": \"Yes\",\n" +
+ " \"ControlParameters\": {\n" +
+ " \"ValidFromDateTime\": \"2017-06-05T15:15:13+00:00\",\n" +
+ " \"ValidToDateTime\": \"2022-07-05T15:15:13+00:00\",\n" +
+ " \"MaximumIndividualAmount\": {\n" +
+ " \"Amount\": \"100.00\",\n" +
+ " \"Currency\": \"GBP\"\n" +
+ " },\n" +
+ " \"PeriodicLimits\": [\n" +
+ " {\n" +
+ " \"Amount\": \"200.00\",\n" +
+ " \"Currency\": \"GBP\",\n" +
+ " \"PeriodAlignment\": \"Consent\",\n" +
+ " \"PeriodType\": \"Week\"\n" +
+ " }\n" +
+ " ]\n" +
+ " },\n" +
+ " \"Initiation\": {\n" +
+ " \"DebtorAccount\": {" +
+ " \"Name\": \"Andrea Smith\", " +
+ " \"SchemeName\": \"OB.SortCodeAccountNumber\", " +
+ " \"Identification\": \"30080012343456\", " +
+ " \"SecondaryIdentification\": \"30080012343456\"" +
+ " }," +
+ " \"CreditorAccount\": {" +
+ " \"Name\": \"Andrea Smith\", " +
+ " \"SchemeName\": \"OB.SortCodeAccountNumber\", " +
+ " \"Identification\": \"30080012343456\", " +
+ " \"SecondaryIdentification\": \"30080012343456\"" +
+ " }," +
+ " \"RemittanceInformation\": {\n" +
+ " \"Reference\": \"Sweepco\"\n" +
+ " }\n" +
+ " }\n" +
+ " },\n" +
+ " \"Risk\": {\n" +
+ " \"PaymentContextCode\": \"PartyToParty\"\n" +
+ " }\n" +
+ "}";
+
+ public static final String VRP_WITHOUT_CONTROLPARAMETERS = "{\n" +
+ " \"Data\": {\n" +
+ " \"ReadRefundAccount\": \"Yes\",\n" +
+ " \"\": {\n" +
+ " \"ValidFromDateTime\": \"2017-06-05T15:15:13+00:00\",\n" +
+ " \"ValidToDateTime\": \"2022-07-05T15:15:13+00:00\",\n" +
+ " \"MaximumIndividualAmount\": {\n" +
+ " \"Amount\": \"100.00\",\n" +
+ " \"Currency\": \"GBP\"\n" +
+ " },\n" +
+ " \"PeriodicLimits\": [\n" +
+ " {\n" +
+ " \"Amount\": \"200.00\",\n" +
+ " \"Currency\": \"GBP\",\n" +
+ " \"PeriodAlignment\": \"Consent\",\n" +
+ " \"PeriodType\": \"Week\"\n" +
+ " }\n" +
+ " ]\n" +
+ " },\n" +
+ " \"Initiation\": {\n" +
+ " \"DebtorAccount\": {" +
+ " \"Name\": \"Andrea Smith\", " +
+ " \"SchemeName\": \"OB.SortCodeAccountNumber\", " +
+ " \"Identification\": \"30080012343456\", " +
+ " \"SecondaryIdentification\": \"30080012343456\"" +
+ " }," +
+ " \"CreditorAccount\": {" +
+ " \"Name\": \"Andrea Smith\", " +
+ " \"SchemeName\": \"OB.SortCodeAccountNumber\", " +
+ " \"Identification\": \"30080012343456\", " +
+ " \"SecondaryIdentification\": \"30080012343456\"" +
+ " }," +
+ " \"RemittanceInformation\": {\n" +
+ " \"Reference\": \"Sweepco\"\n" +
+ " }\n" +
+ " }\n" +
+ " },\n" +
+ " \"Risk\": {\n" +
+ " \"PaymentContextCode\": \"PartyToParty\"\n" +
+ " }\n" +
+ "}";
+
+
+ public static final String VRP_WITHOUT_DATA = "{\n" +
+ " \"\": {\n" +
+ " \"ReadRefundAccount\": \"Yes\",\n" +
+ " \"ControlParameters\": {\n" +
+ " \"ValidFromDateTime\": \"2017-06-05T15:15:13+00:00\",\n" +
+ " \"ValidToDateTime\": \"2022-07-05T15:15:13+00:00\",\n" +
+ " \"MaximumIndividualAmount\": {\n" +
+ " \"Amount\": \"100.00\",\n" +
+ " \"Currency\": \"GBP\"\n" +
+ " },\n" +
+ " \"PeriodicLimits\": [\n" +
+ " {\n" +
+ " \"Amount\": \"200.00\",\n" +
+ " \"Currency\": \"GBP\",\n" +
+ " \"PeriodAlignment\": \"Consent\",\n" +
+ " \"PeriodType\": \"Week\"\n" +
+ " }\n" +
+ " ]\n" +
+ " },\n" +
+ " \"Initiation\": {\n" +
+ " \"DebtorAccount\": {" +
+ " \"Name\": \"Andrea Smith\", " +
+ " \"SchemeName\": \"OB.SortCodeAccountNumber\", " +
+ " \"Identification\": \"30080012343456\", " +
+ " \"SecondaryIdentification\": \"30080012343456\"" +
+ " }," +
+ " \"CreditorAccount\": {" +
+ " \"Name\": \"Andrea Smith\", " +
+ " \"SchemeName\": \"OB.SortCodeAccountNumber\", " +
+ " \"Identification\": \"30080012343456\", " +
+ " \"SecondaryIdentification\": \"30080012343456\"" +
+ " }," +
+ " \"RemittanceInformation\": {\n" +
+ " \"Reference\": \"Sweepco\"\n" +
+ " }\n" +
+ " }\n" +
+ " },\n" +
+ " \"Risk\": {\n" +
+ " \"PaymentContextCode\": \"PartyToParty\"\n" +
+ " }\n" +
+ "}";
+
+ static OffsetDateTime expirationInstant = OffsetDateTime.now().plusDays(50);
+ public static final String PAYMENT_INITIATION = "{\n" +
+ " \"Data\": {\n" +
+ " \"ReadRefundAccount\": \"Yes\",\n" +
+ " \"Authorisation\": {\n" +
+ " \"AuthorisationType\": \"Any\",\n" +
+ " \"CompletionDateTime\": \"" + expirationInstant + "\"\n" +
+ " },\n" +
+ " \"Initiation\": {\n" +
+ " \"InstructionIdentification\": \"ACME412\",\n" +
+ " \"EndToEndIdentification\": \"FRESCO.21302.GFX.20\",\n" +
+ " \"InstructedAmount\": {\n" +
+ " \"Amount\": \"165\",\n" +
+ " \"Currency\": \"GBP\"\n" +
+ " },\n" +
+ " \"DebtorAccount\": {\n" +
+ "\"SchemeName\": \"OB.SortCodeAccountNumber\",\n" +
+ "\"Identification\": \"30080012343456\",\n" +
+ "\"Name\": \"Andrea Smith\",\n" +
+ "\"SecondaryIdentification\": \"30080012343456\"\n" +
+ " },\n" +
+ " \"CreditorAccount\": {\n" +
+ " \"SchemeName\": \"OB.SortCodeAccountNumber\",\n" +
+ " \"Identification\": \"08080021325698\",\n" +
+ " \"Name\": \"ACME Inc\",\n" +
+ " \"SecondaryIdentification\": \"0002\"\n" +
+ " },\n" +
+ " \"RemittanceInformation\": {\n" +
+ " \"Reference\": \"FRESCO-101\",\n" +
+ " \"Unstructured\": \"Internal ops code 5120101\"\n" +
+ " }\n" +
+ " }\n" +
+ " },\n" +
+ " \"Risk\": {\n" +
+ " \"PaymentContextCode\": \"EcommerceGoods\",\n" +
+ " \"MerchantCategoryCode\": \"5967\",\n" +
+ " \"MerchantCustomerIdentification\": \"053598653254\",\n" +
+ " \"DeliveryAddress\": {\n" +
+ " \"AddressLine\": [\n" +
+ " \"Flat 7\",\n" +
+ " \"Acacia Lodge\"\n" +
+ " ],\n" +
+ " \"StreetName\": \"Acacia Avenue\",\n" +
+ " \"BuildingNumber\": \"27\",\n" +
+ " \"PostCode\": \"GU31 2ZZ\",\n" +
+ " \"TownName\": \"Sparsholt\",\n" +
+ " \"CountySubDivision\": [\n" +
+ " \"Wessex\"\n" +
+ " ],\n" +
+ " \"Country\": \"UK\"\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+ public static final String INTERNATIONAL_PAYMENT_INITIATION = "" +
+ "{\n" +
+ " \"Data\": {\n" +
+ " \"ReadRefundAccount\": \"Yes\",\n" +
+ " \"Initiation\": {\n" +
+ " \"InstructionIdentification\": \"ACME412\",\n" +
+ " \"EndToEndIdentification\": \"FRESCO.21302.GFX.20\",\n" +
+ " \"InstructionPriority\": \"Normal\",\n" +
+ " \"CurrencyOfTransfer\": \"USD\",\n" +
+ " \"InstructedAmount\": {\n" +
+ " \"Amount\": \"165.88\",\n" +
+ " \"Currency\": \"GBP\"\n" +
+ " },\n" +
+ " \"DebtorAccount\": {\n" +
+ " \"SchemeName\": \"OB.SortCodeAccountNumber\",\n" +
+ " \"Identification\": \"30080012343456\",\n" +
+ " \"Name\": \"Andrea Smith\",\n" +
+ " \"SecondaryIdentification\": \"30080012343456\"\n" +
+ " },\n" +
+ " \"CreditorAccount\": {\n" +
+ " \"SchemeName\": \"OB.SortCodeAccountNumber\",\n" +
+ " \"Identification\": \"08080021325698\",\n" +
+ " \"Name\": \"ACME Inc\",\n" +
+ " \"SecondaryIdentification\": \"0002\"\n" +
+ " },\n" +
+ " \"RemittanceInformation\": {\n" +
+ " \"Reference\": \"FRESCO-101\",\n" +
+ " \"Unstructured\": \"Internal ops code 5120101\"\n" +
+ " },\n" +
+ " \"ExchangeRateInformation\": {\n" +
+ " \"UnitCurrency\": \"GBP\",\n" +
+ " \"RateType\": \"Actual\"\n" +
+ " }\n" +
+ " }\n" +
+ " },\n" +
+ " \"Risk\": {\n" +
+ " \"PaymentContextCode\": \"TransferToThirdParty\"\n" +
+ " }\n" +
+ "}";
+}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/ConsentExtensionDataProvider.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/ConsentExtensionDataProvider.java
new file mode 100644
index 00000000..7d1a739e
--- /dev/null
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/ConsentExtensionDataProvider.java
@@ -0,0 +1,17 @@
+package com.wso2.openbanking.accelerator.consent.extensions.authorize.vrp.retrieval.flow;
+
+import org.testng.annotations.DataProvider;
+/**
+ * Data Provider for Consent Executor Tests.
+ */
+public class ConsentExtensionDataProvider {
+
+ @DataProvider(name = "PaymentConsentDataDataProvider")
+ Object[][] getPaymentConsentDataDataProvider() {
+
+ return new Object[][]{
+ {ConsentAuthorizeTestConstants.PAYMENT_INITIATION},
+ {ConsentAuthorizeTestConstants.INTERNATIONAL_PAYMENT_INITIATION}
+ };
+ }
+}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/VRPConsentRetrievalStepTest.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/VRPConsentRetrievalStepTest.java
new file mode 100644
index 00000000..aefacc40
--- /dev/null
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/VRPConsentRetrievalStepTest.java
@@ -0,0 +1,291 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
@@ -152,45 +152,46 @@ public static boolean validateExpiryDateTime(String expiryDate) throws ConsentEx
* @param consentDataJSON Consent information object
*/
public static void populateDebtorAccount(JSONObject initiation, JSONArray consentDataJSON) {
+ if (initiation.get(ConsentExtensionConstants.DEBTOR_ACC) != null) {
+ JSONObject debtorAccount = (JSONObject) initiation.get(ConsentExtensionConstants.DEBTOR_ACC);
+ JSONArray debtorAccountArray = new JSONArray();
- if (initiation.get(ConsentExtensionConstants.DEBTOR_ACC) != null) {
- JSONObject debtorAccount = (JSONObject) initiation.get(ConsentExtensionConstants.DEBTOR_ACC);
- JSONArray debtorAccountArray = new JSONArray();
-
- //Adding Debtor Account Scheme Name
- if (debtorAccount.getAsString(ConsentExtensionConstants.SCHEME_NAME) != null) {
- debtorAccountArray.add(ConsentExtensionConstants.SCHEME_NAME_TITLE + " : " +
- debtorAccount.getAsString(ConsentExtensionConstants.SCHEME_NAME));
- }
+ //Adding Debtor Account Scheme Name
+ if (debtorAccount.getAsString(ConsentExtensionConstants.SCHEME_NAME) != null) {
+ debtorAccountArray.add(ConsentExtensionConstants.SCHEME_NAME_TITLE + " : " +
+ debtorAccount.getAsString(ConsentExtensionConstants.SCHEME_NAME));
+ }
- //Adding Debtor Account Identification
- if (debtorAccount.getAsString(ConsentExtensionConstants.IDENTIFICATION) != null) {
- debtorAccountArray.add(ConsentExtensionConstants.IDENTIFICATION_TITLE + " : " +
- debtorAccount.getAsString(ConsentExtensionConstants.IDENTIFICATION));
- }
+ //Adding Debtor Account Identification
+ if (debtorAccount.getAsString(ConsentExtensionConstants.IDENTIFICATION) != null) {
+ debtorAccountArray.add(ConsentExtensionConstants.IDENTIFICATION_TITLE + " : " +
+ debtorAccount.getAsString(ConsentExtensionConstants.IDENTIFICATION));
+ }
- //Adding Debtor Account Name
- if (debtorAccount.getAsString(ConsentExtensionConstants.NAME) != null) {
- debtorAccountArray.add(ConsentExtensionConstants.NAME_TITLE + " : " +
- debtorAccount.getAsString(ConsentExtensionConstants.NAME));
- }
+ //Adding Debtor Account Name
+ if (debtorAccount.getAsString(ConsentExtensionConstants.NAME) != null) {
+ debtorAccountArray.add(ConsentExtensionConstants.NAME_TITLE + " : " +
+ debtorAccount.getAsString(ConsentExtensionConstants.NAME));
+ }
- //Adding Debtor Account Secondary Identification
- if (debtorAccount.getAsString(ConsentExtensionConstants.SECONDARY_IDENTIFICATION) != null) {
- debtorAccountArray.add(ConsentExtensionConstants.SECONDARY_IDENTIFICATION_TITLE + " : " +
- debtorAccount.getAsString(ConsentExtensionConstants.SECONDARY_IDENTIFICATION));
- }
+ //Adding Debtor Account Secondary Identification
+ if (debtorAccount.getAsString(ConsentExtensionConstants.SECONDARY_IDENTIFICATION) != null) {
+ debtorAccountArray.add(ConsentExtensionConstants.SECONDARY_IDENTIFICATION_TITLE + " : " +
+ debtorAccount.getAsString(ConsentExtensionConstants.SECONDARY_IDENTIFICATION));
+ }
- JSONObject jsonElementDebtor = new JSONObject();
- jsonElementDebtor.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.DEBTOR_ACC_TITLE);
- jsonElementDebtor.appendField(ConsentExtensionConstants.DATA_SIMPLE, debtorAccountArray);
- consentDataJSON.add(jsonElementDebtor);
- }
+ JSONObject jsonElementDebtor = new JSONObject();
+ jsonElementDebtor.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.DEBTOR_ACC_TITLE);
+ jsonElementDebtor.appendField(ConsentExtensionConstants.DATA_SIMPLE, debtorAccountArray);
+ consentDataJSON.add(jsonElementDebtor);
}
+ }
+
+
/**
* Method to add debtor account details to consent data to send it to the consent page.
*
@@ -198,7 +199,6 @@ public static void populateDebtorAccount(JSONObject initiation, JSONArray consen
* @param consentDataJSON
*/
public static void populateCreditorAccount(JSONObject initiation, JSONArray consentDataJSON) {
-
if (initiation.get(ConsentExtensionConstants.CREDITOR_ACC) != null) {
JSONObject creditorAccount = (JSONObject) initiation.get(ConsentExtensionConstants.CREDITOR_ACC);
JSONArray creditorAccountArray = new JSONArray();
@@ -326,6 +326,7 @@ public static JSONArray getConsentData(ConsentResource consentResource) {
}
} catch (ParseException e) {
+ log.error(ErrorConstants.CONSENT_RETRIEVAL_ERROR);
throw new ConsentException(ResponseStatus.INTERNAL_SERVER_ERROR, ErrorConstants.CONSENT_RETRIEVAL_ERROR);
}
From a9d43456952b6046714eba7c60dced2ab0f52331 Mon Sep 17 00:00:00 2001
From: hasithan
Date: Fri, 1 Mar 2024 14:13:11 +0530
Subject: [PATCH 064/281] Remove mysql jar related exclusions with the removal
of mysql connector from default pack
---
open-banking-accelerator/accelerators/ob-apim/pom.xml | 1 -
open-banking-accelerator/accelerators/ob-is/pom.xml | 1 -
2 files changed, 2 deletions(-)
diff --git a/open-banking-accelerator/accelerators/ob-apim/pom.xml b/open-banking-accelerator/accelerators/ob-apim/pom.xml
index 24459fda..889a447b 100644
--- a/open-banking-accelerator/accelerators/ob-apim/pom.xml
+++ b/open-banking-accelerator/accelerators/ob-apim/pom.xml
@@ -49,7 +49,6 @@
${project.basedir}/carbon-home/repository/components/lib**/jjwt-0.9.1.jar
- **/mysql-connector-j-8.3.0.jar
diff --git a/open-banking-accelerator/accelerators/ob-is/pom.xml b/open-banking-accelerator/accelerators/ob-is/pom.xml
index 4e03fa99..23f57b98 100644
--- a/open-banking-accelerator/accelerators/ob-is/pom.xml
+++ b/open-banking-accelerator/accelerators/ob-is/pom.xml
@@ -46,7 +46,6 @@
${project.basedir}/carbon-home/repository/components/lib**/commons-beanutils-1.9.4.jar
- **/mysql-connector-j-8.3.0.jar**/hibernate-validator-6.0.20.Final.jar**/validation-api-2.0.1.Final.jar
From 506ff879c92debde7652f483fdf7612f336a1a98 Mon Sep 17 00:00:00 2001
From: Ashirwada
Date: Mon, 4 Mar 2024 10:19:12 +0530
Subject: [PATCH 065/281] Moving Idempotency Validation to consent management
component
---
.../repository/conf/open-banking.xml.j2 | 27 --
.../repository/conf/open-banking.xml.j2 | 13 +
.../pom.xml | 9 +-
.../caching/OpenBankingDistributedCache.java | 153 -------
.../OpenBankingDistributedCacheConstants.java | 59 ---
.../OpenBankingDistributedCacheKey.java | 97 -----
.../caching/OpenBankingDistributedMember.java | 330 ---------------
.../common/util/HTTPClientUtils.java | 1 +
...nBankingDistributedCacheMulticastTest.java | 117 ------
.../OpenBankingDistributedCacheTCPTest.java | 117 ------
.../TestOpenBankingDistributedCache.java | 49 ---
.../TestOpenBankingDistributedCacheKey.java | 35 --
.../common/test/util/SecurityUtilsTest.java | 65 +++
.../src/test/resources/testng.xml | 13 +-
.../pom.xml | 5 -
.../cache/OpenBankingIdempotencyCacheKey.java | 48 ---
...OpenBankingIdempotencyValidationCache.java | 86 ----
...penBankingIdempotencyHandlingExecutor.java | 376 ------------------
...ankingIdempotencyHandlingExecutorImpl.java | 69 ----
...nkingIdempotencyHandlingExecutorTests.java | 229 -----------
.../handler/OBDefaultErrorHandlerTest.java | 106 +++++
.../src/test/resources/testng.xml | 6 +-
.../IdempotencyValidationResult.java | 72 ++++
.../idempotency/IdempotencyValidator.java | 205 ++++++++++
.../pom.xml | 5 +
pom.xml | 6 -
26 files changed, 473 insertions(+), 1825 deletions(-)
delete mode 100644 open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/distributed/caching/OpenBankingDistributedCache.java
delete mode 100644 open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/distributed/caching/OpenBankingDistributedCacheConstants.java
delete mode 100644 open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/distributed/caching/OpenBankingDistributedCacheKey.java
delete mode 100644 open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/distributed/caching/OpenBankingDistributedMember.java
delete mode 100644 open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/distributed/caching/OpenBankingDistributedCacheMulticastTest.java
delete mode 100644 open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/distributed/caching/OpenBankingDistributedCacheTCPTest.java
delete mode 100644 open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/distributed/caching/TestOpenBankingDistributedCache.java
delete mode 100644 open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/distributed/caching/TestOpenBankingDistributedCacheKey.java
create mode 100644 open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/SecurityUtilsTest.java
delete mode 100644 open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/cache/OpenBankingIdempotencyCacheKey.java
delete mode 100644 open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/cache/OpenBankingIdempotencyValidationCache.java
delete mode 100644 open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/idempotency/OpenBankingIdempotencyHandlingExecutor.java
delete mode 100644 open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/java/com/wso2/openbanking/accelerator/gateway/executor/idempotency/OpenBankingIdempotencyHandlingExecutorImpl.java
delete mode 100644 open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/java/com/wso2/openbanking/accelerator/gateway/executor/idempotency/OpenBankingIdempotencyHandlingExecutorTests.java
create mode 100644 open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/java/com/wso2/openbanking/accelerator/gateway/executor/impl/error/handler/OBDefaultErrorHandlerTest.java
create mode 100644 open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidationResult.java
create mode 100644 open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
diff --git a/open-banking-accelerator/accelerators/ob-apim/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2 b/open-banking-accelerator/accelerators/ob-apim/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
index 6e261320..ccbf09ab 100644
--- a/open-banking-accelerator/accelerators/ob-apim/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
+++ b/open-banking-accelerator/accelerators/ob-apim/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
@@ -66,13 +66,6 @@
{{open_banking.gateway.cache.cache_modified_expiry_minutes}}
{% endif %}
-
- {% if open_banking.gateway.cache.idempotency_validation_cache.cache_time_to_live is defined %}
- {{open_banking.gateway.cache.idempotency_validation_cache.cache_time_to_live}}
- {% else %}
- 1440
- {% endif %}
-
@@ -210,26 +203,6 @@
-
-
- {% if open_banking.gateway.idempotency.enabled is defined %}
- {{open_banking.gateway.idempotency.enabled}}
- {% else %}
- false
- {% endif %}
-
- {% if open_banking.gateway.idempotency.allowed_time_duration is defined %}
- {{open_banking.gateway.idempotency.allowed_time_duration}}
- {% else %}
- 1440
- {% endif %}
-
- {% if open_banking.gateway.idempotency.idempotency_key_header is defined %}
- {{open_banking.gateway.idempotency.idempotency_key_header}}
- {% else %}
- x-idempotency-key
- {% endif %}
-
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2 b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
index 9b0a5cfa..ff27c6e3 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
@@ -390,6 +390,19 @@
{% endif %}
+
+ {% if open_banking.gateway.idempotency.enabled is defined %}
+ {{open_banking.gateway.idempotency.enabled}}
+ {% else %}
+ false
+ {% endif %}
+
+ {% if open_banking.gateway.idempotency.allowed_time_duration is defined %}
+ {{open_banking.gateway.idempotency.allowed_time_duration}}
+ {% else %}
+ 1440
+ {% endif %}
+
{% if open_banking.dcr.validator is defined %}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
index 1b417e52..1e7e1927 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
@@ -33,10 +33,6 @@
bundleWSO2 Open Banking - Common component
-
- com.hazelcast
- hazelcast
- org.apache.ws.commons.axiom.wso2axiom
@@ -275,10 +271,7 @@
org.osgi.framework;version="${osgi.framework.imp.pkg.version.range}",
- org.osgi.service.component;version="${osgi.service.component.imp.pkg.version.range}",
- com.hazelcast.config; version="${com.hazelcast.hazelcast.version}",
- com.hazelcast.core; version="${com.hazelcast.hazelcast.version}",
- com.hazelcast.map; version="${com.hazelcast.hazelcast.version}"
+ org.osgi.service.component;version="${osgi.service.component.imp.pkg.version.range}"
!com.wso2.openbanking.accelerator.common.internal,
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/distributed/caching/OpenBankingDistributedCache.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/distributed/caching/OpenBankingDistributedCache.java
deleted file mode 100644
index 145d9cd4..00000000
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/distributed/caching/OpenBankingDistributedCache.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/**
- * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
- *
- * WSO2 LLC. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package com.wso2.openbanking.accelerator.common.distributed.caching;
-
-import com.hazelcast.map.IMap;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.concurrent.TimeUnit;
-
-/**
- * Abstract cache manager for Open Banking Distributed cache.
- *
- * @param Key of the cache.
- * @param Value of the cache.
- */
-public abstract class OpenBankingDistributedCache {
- private final String cacheName;
-
- private static final Log log = LogFactory.getLog(OpenBankingDistributedCache.class);
-
- /**
- * Initialize With unique cache name.
- *
- * @param cacheName Name of the cache.
- */
- public OpenBankingDistributedCache(String cacheName) {
-
- this.cacheName = cacheName;
- if (log.isDebugEnabled()) {
- log.debug(String.format("Distributed Cache initialized for %s.", cacheName.replaceAll("[\r\n]", "")));
- }
- }
-
- /**
- * Get from cache.
- *
- * @param key cache key.
- * @return cache.
- */
- public V getFromCache(K key) {
-
- if (isEnabled()) {
-
- IMap cache = getBaseCache();
-
- if (cache.containsKey(key)) {
- if (log.isDebugEnabled()) {
- log.debug(String.format("Found cache entry `%s` in cache %s.",
- key.toString().replaceAll("[\r\n]", ""), cacheName.replaceAll("[\r\n]", "")));
- }
- return cache.get(key);
- } else {
- if (log.isDebugEnabled()) {
- log.debug(String.format("Cache entry `%s` is not Found in cache %s.",
- key.toString().replaceAll("[\r\n]", ""), cacheName.replaceAll("[\r\n]", "")));
- }
- return null;
- }
- } else {
- log.debug("Distributed cache is Disabled.");
- return null;
- }
- }
-
- /**
- * Add Object to cache.
- *
- * @param key cache key.
- * @param value object to be cached.
- */
- public void addToCache(K key, V value) {
- if (isEnabled()) {
- IMap cache = getBaseCache();
- if (log.isDebugEnabled()) {
- log.debug(String.format("`%s` added into cache %s.", key.toString().replaceAll("[\r\n]", ""),
- cacheName.replaceAll("[\r\n]", "")));
- }
- cache.put(key, value, getCacheTimeToLiveMinutes(), TimeUnit.MINUTES);
- } else {
- log.debug("Distributed cache is Disabled.");
- }
- }
-
- /**
- * Remove from cache.
- *
- * @param key cache key.
- */
- public void removeFromCache(K key) {
- if (isEnabled()) {
- if (log.isDebugEnabled()) {
- log.debug(String.format("`%s` removed from cache %s.", key.toString().replaceAll("[\r\n]", ""),
- cacheName.replaceAll("[\r\n]", "")));
- }
- IMap cache = getBaseCache();
- cache.remove(key);
- } else {
- log.debug("Distributed cache is Disabled.");
- }
- }
-
- /**
- * Method to check if the cache is empty.
- *
- * @return true if empty, false if populated.
- */
- public boolean isEmpty() {
- return getBaseCache().isEmpty();
- }
-
- /**
- * Get the clustered cache.
- *
- * @return cache map.
- */
- private IMap getBaseCache() {
- return OpenBankingDistributedMember.of().getHazelcastInstance().getMap(this.cacheName);
- }
-
- /**
- * Method to get if the Distributed caching is enabled.
- *
- * @return True if enabled, false if disabled.
- */
- private boolean isEnabled() {
- return OpenBankingDistributedMember.of().isEnabled();
- }
-
- /**
- * Get Cache expiry time upon modification in minutes.
- *
- * @return integer denoting number of minutes.
- */
- public abstract int getCacheTimeToLiveMinutes();
-
-}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/distributed/caching/OpenBankingDistributedCacheConstants.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/distributed/caching/OpenBankingDistributedCacheConstants.java
deleted file mode 100644
index 58d5bf75..00000000
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/distributed/caching/OpenBankingDistributedCacheConstants.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
- *
- * WSO2 LLC. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package com.wso2.openbanking.accelerator.common.distributed.caching;
-
-/**
- * Open banking distributed cache constants.
- */
-public class OpenBankingDistributedCacheConstants {
-
- // Distributed cache cluster name.
- public static final String CLUSTER_NAME = "OB_DISTRIBUTED_CACHE";
-
- // Common constants for both TCP and Multicast.
- public static final String ENABLED = "DistributedCache.Enabled";
- public static final String HOST_NAME = "DistributedCache.HostName";
- public static final String PORT = "DistributedCache.Port";
- public static final String DISCOVERY_MECHANISM = "DistributedCache.DiscoveryMechanism";
-
- // Constants used for Multicast.
- public static final String MULTICAST = "Multicast";
- public static final String MULTICAST_GROUP = "DistributedCache.MulticastGroup";
- public static final String MULTICAST_PORT = "DistributedCache.MulticastPort";
- public static final String TRUSTED_INTERFACES = "DistributedCache.TrustedInterfaces.TrustedInterface";
-
- // Constants used for TCP.
- public static final String TCP = "TCP";
- public static final String MEMBERS = "DistributedCache.Members.Member";
-
- // Constants for hazelcast properties.
- public static final String PROPERTY_MAX_HEARTBEAT = "DistributedCache.Properties.MaxHeartbeat";
- public static final String PROPERTY_MAX_MASTER_CONFIRMATION = "DistributedCache.Properties.MasterConfirmation";
- public static final String PROPERTY_MERGE_FIRST_RUN_DELAY = "DistributedCache.Properties.MergeFirstRunDelay";
- public static final String PROPERTY_MERGE_NEXT_RUN_DELAY = "DistributedCache.Properties.MergeNextRunDelay";
- public static final String PROPERTY_LOGGING_TYPE = "DistributedCache.Properties.LoggingType";
-
- // Hazelcast Constants for hazelcast properties.
- public static final String HAZELCAST_PROPERTY_MAX_HEARTBEAT = "hazelcast.max.no.heartbeat.seconds";
- public static final String HAZELCAST_PROPERTY_MAX_MASTER_CONFIRMATION = "hazelcast.max.no.master." +
- "confirmation.seconds";
- public static final String HAZELCAST_PROPERTY_MERGE_FIRST_RUN_DELAY = "hazelcast.merge.first.run.delay.seconds";
- public static final String HAZELCAST_PROPERTY_MERGE_NEXT_RUN_DELAY = "hazelcast.merge.next.run.delay.seconds";
- public static final String HAZELCAST_PROPERTY_LOGGING_TYPE = "hazelcast.logging.type";
-}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/distributed/caching/OpenBankingDistributedCacheKey.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/distributed/caching/OpenBankingDistributedCacheKey.java
deleted file mode 100644
index b1818a73..00000000
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/distributed/caching/OpenBankingDistributedCacheKey.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
- *
- * WSO2 LLC. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package com.wso2.openbanking.accelerator.common.distributed.caching;
-
-import java.io.Serializable;
-import java.util.Objects;
-
-/**
- * Abstract class for Open Banking Distributed Cache Key.
- */
-public class OpenBankingDistributedCacheKey implements Serializable {
-
- private static final long serialVersionUID = -2106706990466051087L;
- private String cacheKey;
-
-
- /**
- * public constructor for OpenBankingDistributedCacheKey.
- *
- * @param cacheKey String cache key.
- */
- public OpenBankingDistributedCacheKey(String cacheKey) {
- setCacheKey(cacheKey);
- }
-
- /**
- * Get Instance OpenBankingDistributedCacheKey.
- *
- * @param cacheKey String cache key.
- * @return new OpenBankingDistributedCacheKey instance.
- */
- public static OpenBankingDistributedCacheKey of(String cacheKey) {
- return new OpenBankingDistributedCacheKey(cacheKey);
- }
-
- /**
- * Getter for cacheKey.
- *
- * @return String cacheKey.
- */
- public String getCacheKey() {
- return this.cacheKey;
- }
-
- /**
- * Setter for cacheKey.
- *
- * @param cacheKey String cacheKey.
- */
- public void setCacheKey(String cacheKey) {
- this.cacheKey = cacheKey;
- }
-
- /**
- * Equals Method for OpenBankingDistributedCacheKey objects.
- *
- * @param o Object.
- * @return True if equal, false if not-equal.
- */
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- OpenBankingDistributedCacheKey that = (OpenBankingDistributedCacheKey) o;
- return Objects.equals(getCacheKey(), that.getCacheKey());
- }
-
- /**
- * hashcode for OpenBankingDistributedCacheKey.
- *
- * @return hashcode.
- */
- @Override
- public int hashCode() {
- return Objects.hash(getCacheKey());
- }
-}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/distributed/caching/OpenBankingDistributedMember.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/distributed/caching/OpenBankingDistributedMember.java
deleted file mode 100644
index 4c4147cf..00000000
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/distributed/caching/OpenBankingDistributedMember.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/**
- * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
- *
- * WSO2 LLC. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package com.wso2.openbanking.accelerator.common.distributed.caching;
-
-import com.hazelcast.config.Config;
-import com.hazelcast.config.JoinConfig;
-import com.hazelcast.config.MulticastConfig;
-import com.hazelcast.config.NetworkConfig;
-import com.hazelcast.config.TcpIpConfig;
-import com.hazelcast.core.Hazelcast;
-import com.hazelcast.core.HazelcastInstance;
-import com.wso2.openbanking.accelerator.common.config.OpenBankingConfigParser;
-import com.wso2.openbanking.accelerator.common.util.SecurityUtils;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.Properties;
-
-import static com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCacheConstants.CLUSTER_NAME;
-import static com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCacheConstants.DISCOVERY_MECHANISM;
-import static com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCacheConstants.ENABLED;
-import static com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCacheConstants.HAZELCAST_PROPERTY_LOGGING_TYPE;
-import static com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCacheConstants.HAZELCAST_PROPERTY_MAX_HEARTBEAT;
-import static com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCacheConstants.HAZELCAST_PROPERTY_MAX_MASTER_CONFIRMATION;
-import static com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCacheConstants.HAZELCAST_PROPERTY_MERGE_FIRST_RUN_DELAY;
-import static com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCacheConstants.HAZELCAST_PROPERTY_MERGE_NEXT_RUN_DELAY;
-import static com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCacheConstants.HOST_NAME;
-import static com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCacheConstants.MEMBERS;
-import static com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCacheConstants.MULTICAST;
-import static com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCacheConstants.MULTICAST_GROUP;
-import static com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCacheConstants.MULTICAST_PORT;
-import static com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCacheConstants.PORT;
-import static com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCacheConstants.PROPERTY_LOGGING_TYPE;
-import static com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCacheConstants.PROPERTY_MAX_HEARTBEAT;
-import static com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCacheConstants.PROPERTY_MAX_MASTER_CONFIRMATION;
-import static com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCacheConstants.PROPERTY_MERGE_FIRST_RUN_DELAY;
-import static com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCacheConstants.PROPERTY_MERGE_NEXT_RUN_DELAY;
-import static com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCacheConstants.TCP;
-import static com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCacheConstants.TRUSTED_INTERFACES;
-
-/**
- * Singleton class to create a hazelcast cluster member.
- */
-public class OpenBankingDistributedMember {
- private boolean enabled;
- private static volatile OpenBankingDistributedMember openBankingDistributedMember;
- private final HazelcastInstance hazelcastInstance;
- private static final Map configurations = OpenBankingConfigParser.getInstance().getConfiguration();
-
- private static final Log log = LogFactory.getLog(OpenBankingDistributedMember.class);
-
- /**
- * Private constructor.
- */
- private OpenBankingDistributedMember() {
- setEnabled();
-
- Config hazelcastConfig = new Config();
- hazelcastConfig.setClusterName(CLUSTER_NAME);
-
- setProperties(hazelcastConfig);
-
- NetworkConfig network = hazelcastConfig.getNetworkConfig();
-
- setNetworkConfigurations(network);
-
- this.hazelcastInstance = Hazelcast.newHazelcastInstance(hazelcastConfig);
- }
-
- /**
- * Method to get the singleton object.
- *
- * @return distributedMember.
- */
- public static OpenBankingDistributedMember of() {
- if (openBankingDistributedMember == null) {
- synchronized (OpenBankingDistributedMember.class) {
- if (openBankingDistributedMember == null) {
- openBankingDistributedMember = new OpenBankingDistributedMember();
- }
- }
- }
- return openBankingDistributedMember;
- }
-
- /**
- * Method to destroy the singleton instance.
- */
- public static synchronized void shutdown() {
- openBankingDistributedMember.getHazelcastInstance().shutdown();
- openBankingDistributedMember = null;
- log.debug("Shutdown distributed cache member.");
- }
-
- /**
- * Getter for enabled.
- *
- * @return Boolean enabled.
- */
- public boolean isEnabled() {
- return this.enabled;
- }
-
- /**
- * Setter for enabled, using the config file.
- */
- public void setEnabled() {
- Object isEnableConfiguration = configurations.get(ENABLED);
- if (isEnableConfiguration != null) {
- String isEnableConfigurationString = isEnableConfiguration.toString();
- setEnabled(isEnableConfigurationString.equals("true"));
- }
- }
-
- /**
- * Setter of enabled.
- *
- * @param enabled Boolean enabled.
- */
- public void setEnabled(boolean enabled) {
- if (enabled) {
- log.debug("Distributed Caching enabled");
- } else {
- log.debug("Distributed Caching disabled");
- }
- this.enabled = enabled;
- }
-
- /**
- * Getter for hazelcast instance.
- *
- * @return this.hazelcastInstance.
- */
- public HazelcastInstance getHazelcastInstance() {
- return this.hazelcastInstance;
- }
-
- /**
- * Method to set hazelcast properties.
- *
- * @param hazelcastConfig hazelcastConfig.
- */
- @SuppressFBWarnings("CRLF_INJECTION_LOGS")
- // Suppressed content - hazelcastConfig.getProperties()
- // Suppression reason - Warning are appearing on Properties, not strings. Also the properties will be set in config
- // by the admin
- // Suppressed warning count - 1
- private synchronized void setProperties(Config hazelcastConfig) {
-
- Properties hazelcastProperties = new Properties();
-
- setProperty(hazelcastProperties, PROPERTY_MAX_HEARTBEAT, HAZELCAST_PROPERTY_MAX_HEARTBEAT);
- setProperty(hazelcastProperties, PROPERTY_MAX_MASTER_CONFIRMATION, HAZELCAST_PROPERTY_MAX_MASTER_CONFIRMATION);
- setProperty(hazelcastProperties, PROPERTY_MERGE_FIRST_RUN_DELAY, HAZELCAST_PROPERTY_MERGE_FIRST_RUN_DELAY);
- setProperty(hazelcastProperties, PROPERTY_MERGE_NEXT_RUN_DELAY, HAZELCAST_PROPERTY_MERGE_NEXT_RUN_DELAY);
- setProperty(hazelcastProperties, PROPERTY_LOGGING_TYPE, HAZELCAST_PROPERTY_LOGGING_TYPE);
-
- hazelcastConfig.setProperties(hazelcastProperties);
-
- if (log.isDebugEnabled()) {
- log.debug("Hazelcast Properties : " + hazelcastConfig.getProperties());
- }
- }
-
- /**
- * Method to set hazelcast property.
- *
- * @param property Property.
- * @param configurationName Name of the configuration in config file.
- * @param hazelcastProperty hazelcast configuration.
- */
- private void setProperty(Properties property, String configurationName, String hazelcastProperty) {
- Object configuration = configurations.get(configurationName);
- if (configuration != null) {
- String configurationString = configuration.toString();
- property.setProperty(hazelcastProperty, configurationString);
- }
- }
-
- /**
- * Method to set hazelcast network configurations.
- *
- * @param network network.
- */
- private synchronized void setNetworkConfigurations(NetworkConfig network) {
-
- // Configuring host name of the hazelcast instance.
- Object hostName = configurations.get(HOST_NAME);
- if (hostName != null) {
- String hostNameString = hostName.toString();
- network.setPublicAddress(hostNameString);
- }
-
- // Configuring port of the hazelcast instance.
- Object port = configurations.get(PORT);
- if (port != null) {
- String portString = port.toString();
- int portInt = Integer.parseInt(portString);
- network.setPort(portInt);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("Network is set to " + network.getPublicAddress().replaceAll("[\r\n]", "") + ":" +
- network.getPort());
- }
-
- // Configuring the discovery mechanism of the hazelcast instance.
- JoinConfig join = network.getJoin();
- Object discoveryMechanism = configurations.get(DISCOVERY_MECHANISM);
- if (discoveryMechanism != null) { // When discovery method is configured.
-
- String discoveryMechanismString = discoveryMechanism.toString();
-
- if (discoveryMechanismString.equals(TCP)) {
- // Discovery method TCP.
- setConfigurationsTCP(join);
- } else if (discoveryMechanismString.equals(MULTICAST)) {
- // Discovery method Multicast.
- setConfigurationsMulticast(join);
- }
- } else { // Defaulting Multicast when discovery method is not configured.
- setConfigurationsMulticast(join);
- }
- }
-
- /**
- * Method to set discovery mechanism TCP.
- *
- * @param join JoinConfig join.
- */
- @SuppressFBWarnings("CRLF_INJECTION_LOGS")
- // Suppressed content - tcpipConfig.getMembers()
- // Suppression reason - False positive: New lines are already removed
- // Suppressed warning count - 1
- private void setConfigurationsTCP(JoinConfig join) {
- log.debug("Discovery mechanism : TCP");
- join.getMulticastConfig().setEnabled(false);
- TcpIpConfig tcpipConfig = join.getTcpIpConfig();
- tcpipConfig.setEnabled(true);
-
- // Configuring TCP members.
- Object members = configurations.get(MEMBERS);
- if (members != null) {
- ArrayList membersList = new ArrayList<>();
- if (members instanceof ArrayList) {
- membersList.addAll((ArrayList) members);
- } else if (members instanceof String) {
- membersList.add((String) members);
- }
- for (String member : membersList) {
- tcpipConfig.addMember(member.trim());
- }
- }
- if (log.isDebugEnabled()) {
- log.debug("Members: " + SecurityUtils.sanitize(tcpipConfig.getMembers()));
- }
- }
-
- /**
- * Method to set discovery mechanism Multicast.
- *
- * @param join JoinConfig join.
- */
- @SuppressFBWarnings("CRLF_INJECTION_LOGS")
- // Suppressed content - multicastConfig.getTrustedInterfaces()
- // Suppression reason - False positive: New lines are already removed
- // Suppressed warning count - 1
- private void setConfigurationsMulticast(JoinConfig join) {
- log.debug("Discovery mechanism : Multicast");
- join.getTcpIpConfig().setEnabled(false);
- MulticastConfig multicastConfig = join.getMulticastConfig();
- multicastConfig.setEnabled(true);
-
- // Configuring multicast group.
- Object multicastGroup = configurations.get(MULTICAST_GROUP);
- if (multicastGroup != null) {
- String multicastGroupString = multicastGroup.toString();
- multicastConfig.setMulticastGroup(multicastGroupString);
- }
-
- // Configuring multicast port.
- Object multicastPort = configurations.get(MULTICAST_PORT);
- if (multicastPort != null) {
- String multicastPortString = multicastPort.toString();
- int multicastPortInt = Integer.parseInt(multicastPortString);
- multicastConfig.setMulticastPort(multicastPortInt);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("Discovery mechanism is set to Multicast.\n\tMulticast Group: " +
- multicastConfig.getMulticastGroup().replaceAll("[\r\n]", "") +
- "\n\tMulticast Port: " + multicastConfig.getMulticastPort());
- }
- // Configuring trusted interfaces.
- Object trustedInterfaces = configurations.get(TRUSTED_INTERFACES);
- if (trustedInterfaces != null) {
- ArrayList trustedInterfacesList = new ArrayList<>();
- if (trustedInterfaces instanceof ArrayList) {
- trustedInterfacesList.addAll((ArrayList) trustedInterfaces);
- } else if (trustedInterfaces instanceof String) {
- trustedInterfacesList.add((String) trustedInterfaces);
- }
- for (String trustedInterface : trustedInterfacesList) {
- multicastConfig.addTrustedInterface(trustedInterface.trim());
- }
- }
- if (log.isDebugEnabled()) {
- log.debug("\n\tTrusted Interfaces: " + SecurityUtils.sanitize(multicastConfig.getTrustedInterfaces()));
- }
- }
-}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/HTTPClientUtils.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/HTTPClientUtils.java
index 37996812..5e84500f 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/HTTPClientUtils.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/HTTPClientUtils.java
@@ -66,6 +66,7 @@ public class HTTPClientUtils {
* @return Closeable https client
* @throws OpenBankingException OpenBankingException exception
*/
+ @Generated(message = "Ignoring because ServerConfiguration cannot be mocked")
public static CloseableHttpClient getHttpsClient() throws OpenBankingException {
SSLConnectionSocketFactory sslsf = createSSLConnectionSocketFactory();
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/distributed/caching/OpenBankingDistributedCacheMulticastTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/distributed/caching/OpenBankingDistributedCacheMulticastTest.java
deleted file mode 100644
index 76cfa338..00000000
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/distributed/caching/OpenBankingDistributedCacheMulticastTest.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
- *
- * WSO2 LLC. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package com.wso2.openbanking.accelerator.common.test.distributed.caching;
-
-import com.wso2.openbanking.accelerator.common.config.OpenBankingConfigParser;
-import com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCacheConstants;
-import com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedMember;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PowerMockIgnore;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.testng.PowerMockTestCase;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Unit test for open banking distributed cache with Multicast discovery method.
- */
-@PowerMockIgnore({"jdk.internal.reflect.*", "javax.management.*"})
-@PrepareForTest({OpenBankingConfigParser.class})
-public class OpenBankingDistributedCacheMulticastTest extends PowerMockTestCase {
-
-
- private static TestOpenBankingDistributedCache cacheMulticast;
-
- @Mock
- OpenBankingConfigParser openBankingConfigParser;
-
-
- @BeforeClass
- public void beforeTests() {
- MockitoAnnotations.initMocks(this);
-
- Map configsMulticast = new HashMap<>();
- configsMulticast.put(OpenBankingDistributedCacheConstants.ENABLED, "true");
- configsMulticast.put(OpenBankingDistributedCacheConstants.HOST_NAME, "localhost");
- configsMulticast.put(OpenBankingDistributedCacheConstants.PORT, "5721");
- configsMulticast.put(OpenBankingDistributedCacheConstants.DISCOVERY_MECHANISM, "Multicast");
- configsMulticast.put(OpenBankingDistributedCacheConstants.MULTICAST_GROUP, "224.2.2.3");
- configsMulticast.put(OpenBankingDistributedCacheConstants.MULTICAST_PORT, "54321");
- ArrayList interfaces = new ArrayList<>();
- interfaces.add("192.168.1.100-110");
- configsMulticast.put(OpenBankingDistributedCacheConstants.TRUSTED_INTERFACES, interfaces);
- configsMulticast.put(OpenBankingDistributedCacheConstants.PROPERTY_LOGGING_TYPE, "none");
-
- Mockito.when(openBankingConfigParser.getConfiguration()).thenReturn(configsMulticast);
-
- PowerMockito.mockStatic(OpenBankingConfigParser.class);
- PowerMockito.when(OpenBankingConfigParser.getInstance())
- .thenReturn(openBankingConfigParser);
-
- cacheMulticast = new TestOpenBankingDistributedCache("test-cache-multicast");
-
- }
-
- @Test(priority = 1)
- public void addGetTestMulticast() {
- TestOpenBankingDistributedCacheKey key = new TestOpenBankingDistributedCacheKey("test-cache-key");
- cacheMulticast.addToCache(key, "cache-body");
- String fromCache = null;
- if (!cacheMulticast.isEmpty()) {
- fromCache = cacheMulticast.getFromCache(key);
- }
-
- Assert.assertEquals(fromCache, "cache-body");
- }
-
- @Test(priority = 2)
- public void removeTestMulticast() {
- TestOpenBankingDistributedCacheKey key = new TestOpenBankingDistributedCacheKey("test-cache-key");
- cacheMulticast.removeFromCache(key);
-
- String fromCache = cacheMulticast.getFromCache(key);
-
- Assert.assertNull(fromCache);
- }
-
- @Test(priority = 3)
- public void cacheEvictionTestMulticast() throws InterruptedException {
- TestOpenBankingDistributedCacheKey key = new TestOpenBankingDistributedCacheKey("test-cache-key");
- cacheMulticast.addToCache(key, "cache-body");
- TimeUnit.MINUTES.sleep(2);
-
- String fromCache = cacheMulticast.getFromCache(key);
- Assert.assertNull(fromCache);
- }
-
- @AfterClass
- public void after() {
- OpenBankingDistributedMember.of().shutdown();
- }
-}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/distributed/caching/OpenBankingDistributedCacheTCPTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/distributed/caching/OpenBankingDistributedCacheTCPTest.java
deleted file mode 100644
index 0b65dae1..00000000
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/distributed/caching/OpenBankingDistributedCacheTCPTest.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
- *
- * WSO2 LLC. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package com.wso2.openbanking.accelerator.common.test.distributed.caching;
-
-import com.wso2.openbanking.accelerator.common.config.OpenBankingConfigParser;
-import com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCacheConstants;
-import com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedMember;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PowerMockIgnore;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.testng.PowerMockTestCase;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-
-/**
- * Unit test for open banking distributed cache with TCP discovery method.
- */
-@PowerMockIgnore({"jdk.internal.reflect.*", "javax.management.*"})
-@PrepareForTest({OpenBankingConfigParser.class})
-public class OpenBankingDistributedCacheTCPTest extends PowerMockTestCase {
-
-
- private static TestOpenBankingDistributedCache cacheTCP;
-
- @Mock
- OpenBankingConfigParser openBankingConfigParser;
-
-
- @BeforeClass
- public void beforeTests() {
- MockitoAnnotations.initMocks(this);
-
- Map configsTCP = new HashMap<>();
- configsTCP.put(OpenBankingDistributedCacheConstants.ENABLED, "true");
- configsTCP.put(OpenBankingDistributedCacheConstants.HOST_NAME, "localhost");
- configsTCP.put(OpenBankingDistributedCacheConstants.PORT, "5721");
- configsTCP.put(OpenBankingDistributedCacheConstants.DISCOVERY_MECHANISM, "TCP");
- ArrayList members = new ArrayList<>();
- members.add("localhost:5722");
- configsTCP.put(OpenBankingDistributedCacheConstants.MEMBERS, members);
- configsTCP.put(OpenBankingDistributedCacheConstants.PROPERTY_LOGGING_TYPE, "none");
-
- Mockito.when(openBankingConfigParser.getConfiguration()).thenReturn(configsTCP);
-
- PowerMockito.mockStatic(OpenBankingConfigParser.class);
- PowerMockito.when(OpenBankingConfigParser.getInstance())
- .thenReturn(openBankingConfigParser);
-
- cacheTCP = new TestOpenBankingDistributedCache("test-cache-tcp");
-
- }
-
- @Test(priority = 1)
- public void addGetTestTCP() {
- TestOpenBankingDistributedCacheKey key = new TestOpenBankingDistributedCacheKey("test-cache-key");
- cacheTCP.addToCache(key, "cache-body");
- String fromCache = null;
- if (!cacheTCP.isEmpty()) {
- fromCache = cacheTCP.getFromCache(key);
- }
-
- Assert.assertEquals(fromCache, "cache-body");
- }
-
- @Test(priority = 2)
- public void removeTestTCP() {
- TestOpenBankingDistributedCacheKey key = new TestOpenBankingDistributedCacheKey("test-cache-key");
- cacheTCP.removeFromCache(key);
-
- String fromCache = cacheTCP.getFromCache(key);
-
- Assert.assertNull(fromCache);
- }
-
- @Test(priority = 3)
- public void cacheEvictionTestTCP() throws InterruptedException {
- TestOpenBankingDistributedCacheKey key = new TestOpenBankingDistributedCacheKey("test-cache-key");
- cacheTCP.addToCache(key, "cache-body");
- TimeUnit.MINUTES.sleep(2);
-
- String fromCache = cacheTCP.getFromCache(key);
- Assert.assertNull(fromCache);
- }
-
-
- @AfterClass
- public void after() {
- OpenBankingDistributedMember.of().shutdown();
- }
-}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/distributed/caching/TestOpenBankingDistributedCache.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/distributed/caching/TestOpenBankingDistributedCache.java
deleted file mode 100644
index 01c5a027..00000000
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/distributed/caching/TestOpenBankingDistributedCache.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
- *
- * WSO2 LLC. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package com.wso2.openbanking.accelerator.common.test.distributed.caching;
-
-import com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCache;
-
-/**
- * TestOpenBankingDistributedCache.
- */
-public class TestOpenBankingDistributedCache
- extends OpenBankingDistributedCache {
-
- int cacheTimeToLiveMinutes;
-
- /**
- * Initialize With unique cache name.
- *
- * @param cacheName Name of the cache.
- */
- public TestOpenBankingDistributedCache(String cacheName) {
- super(cacheName);
- setCacheTimeToLiveMinutes();
- }
-
- @Override
- public int getCacheTimeToLiveMinutes() {
- return this.cacheTimeToLiveMinutes;
- }
-
- public void setCacheTimeToLiveMinutes() {
- this.cacheTimeToLiveMinutes = 2;
- }
-}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/distributed/caching/TestOpenBankingDistributedCacheKey.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/distributed/caching/TestOpenBankingDistributedCacheKey.java
deleted file mode 100644
index 639eaf35..00000000
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/distributed/caching/TestOpenBankingDistributedCacheKey.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
- *
- * WSO2 LLC. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package com.wso2.openbanking.accelerator.common.test.distributed.caching;
-
-import com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCacheKey;
-
-/**
- * TestOpenBankingDistributedCacheKey.
- */
-public class TestOpenBankingDistributedCacheKey extends OpenBankingDistributedCacheKey {
-
- public TestOpenBankingDistributedCacheKey(String cacheKey) {
- super(cacheKey);
- }
-
- public static OpenBankingDistributedCacheKey of(String cacheKey) {
- return new TestOpenBankingDistributedCacheKey(cacheKey);
- }
-}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/SecurityUtilsTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/SecurityUtilsTest.java
new file mode 100644
index 00000000..d15625b0
--- /dev/null
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/SecurityUtilsTest.java
@@ -0,0 +1,65 @@
+/**
+ * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.openbanking.accelerator.common.test.util;
+
+import com.wso2.openbanking.accelerator.common.util.SecurityUtils;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Tests Common Security Utils.
+ */
+public class SecurityUtilsTest {
+
+ @Test
+ public void testSanitizeString() {
+ String sanitizedString = SecurityUtils.sanitizeString("tests\nsanitizing");
+ Assert.assertFalse(sanitizedString.contains("\n"));
+ }
+
+ @Test
+ public void testSanitizeStringList() {
+ List sanitizedList = SecurityUtils.sanitize(List.of(
+ "tests\nsanitizing",
+ "tests\nsanitizing",
+ "tests\nsanitizing"
+ )
+ );
+ Assert.assertFalse(sanitizedList.stream().anyMatch(s -> s.contains("\n")));
+ }
+
+ @Test
+ public void testSanitizeStringSet() {
+ Set sanitizedList = SecurityUtils.sanitize(Set.of(
+ "tests\nsanitizing",
+ "tests\nsanitizingtext",
+ "tests\nsanitizingwords"
+ )
+ );
+ Assert.assertFalse(sanitizedList.stream().anyMatch(s -> s.contains("\n")));
+ }
+
+ @Test
+ public void testContainSpecialChars() {
+ Assert.assertTrue(SecurityUtils.containSpecialChars("tests&sanitizing"));
+ }
+}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/resources/testng.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/resources/testng.xml
index b791b6f8..2eaab446 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/resources/testng.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/resources/testng.xml
@@ -50,19 +50,14 @@
-
-
-
-
-
-
+
-
+
-
+
-
+
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
index c4a8b9bb..b4eaa95b 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
@@ -147,11 +147,6 @@
-
- com.hazelcast
- hazelcast
- test
- org.wso2.orbit.com.nimbusdsnimbus-jose-jwt
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/cache/OpenBankingIdempotencyCacheKey.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/cache/OpenBankingIdempotencyCacheKey.java
deleted file mode 100644
index 6d9dd690..00000000
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/cache/OpenBankingIdempotencyCacheKey.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
- *
- * WSO2 LLC. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package com.wso2.openbanking.accelerator.gateway.cache;
-
-import com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCacheKey;
-
-/**
- * Cache Key for Open Banking Idempotency cache.
- */
-public class OpenBankingIdempotencyCacheKey extends OpenBankingDistributedCacheKey {
-
- private static final long serialVersionUID = -6635236272993690731L;
-
- /**
- * public constructor for OpenBankingDistributedCacheKey.
- *
- * @param cacheKey String cache key.
- */
- public OpenBankingIdempotencyCacheKey(String cacheKey) {
- super(cacheKey);
- }
-
- /**
- * Static method to create a cache key.
- *
- * @param cacheKey cache key in string.
- * @return OpenBankingIdempotencyCacheKey.
- */
- public static OpenBankingIdempotencyCacheKey of(String cacheKey) {
- return new OpenBankingIdempotencyCacheKey(cacheKey);
- }
-}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/cache/OpenBankingIdempotencyValidationCache.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/cache/OpenBankingIdempotencyValidationCache.java
deleted file mode 100644
index 1a683c22..00000000
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/cache/OpenBankingIdempotencyValidationCache.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
- *
- * WSO2 LLC. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package com.wso2.openbanking.accelerator.gateway.cache;
-
-import com.wso2.openbanking.accelerator.common.config.OpenBankingConfigParser;
-import com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCache;
-import com.wso2.openbanking.accelerator.gateway.util.IdempotencyConstants;
-
-import java.util.HashMap;
-
-/**
- * Cache definition to store Request against the idempotency key.
- */
-public class OpenBankingIdempotencyValidationCache
- extends OpenBankingDistributedCache> {
-
- private final int cacheTimeToLiveMinutes;
- private static final String cacheName = "Idempotency-Validation-Cache";
- private static volatile OpenBankingIdempotencyValidationCache idempotencyValidationCache;
-
- /**
- * Initialize With unique cache name.
- *
- * @param cacheName Name of the cache.
- */
- private OpenBankingIdempotencyValidationCache(String cacheName) {
- super(cacheName);
- this.cacheTimeToLiveMinutes = setCacheTimeToLiveMinutes();
- }
-
- /**
- * Creating a singleton OpenBankingIdempotencyValidationCache object.
- *
- * @return OpenBankingIdempotencyValidationCache object.
- */
- public static OpenBankingIdempotencyValidationCache getInstance() {
- if (idempotencyValidationCache == null) {
- synchronized (OpenBankingIdempotencyValidationCache.class) {
- if (idempotencyValidationCache == null) {
- idempotencyValidationCache = new OpenBankingIdempotencyValidationCache(
- OpenBankingIdempotencyValidationCache.cacheName);
- }
- }
- }
- return idempotencyValidationCache;
- }
-
- /**
- * Getter for cache time to live in minutes.
- *
- * @return cache time to live for Open Banking Idempotency Validation Cache.
- */
- @Override
- public int getCacheTimeToLiveMinutes() {
- return this.cacheTimeToLiveMinutes;
- }
-
- /**
- * Method to read cache time to live from configurations.
- *
- * @return Open Banking Idempotency Validation Cache time to live in minutes as set configurations,
- * if configuration is not set return 3600 as default.
- */
- public int setCacheTimeToLiveMinutes() {
- String cacheTimeToLive = (String) OpenBankingConfigParser.getInstance().getConfiguration()
- .get(IdempotencyConstants.IDEMPOTENCY_CACHE_TIME_TO_LIVE);
-
- return cacheTimeToLive == null ? 3600 : Integer.parseInt(cacheTimeToLive);
- }
-}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/idempotency/OpenBankingIdempotencyHandlingExecutor.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/idempotency/OpenBankingIdempotencyHandlingExecutor.java
deleted file mode 100644
index 3bd11c33..00000000
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/idempotency/OpenBankingIdempotencyHandlingExecutor.java
+++ /dev/null
@@ -1,376 +0,0 @@
-/**
- * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
- *
- * WSO2 LLC. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package com.wso2.openbanking.accelerator.gateway.executor.idempotency;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.wso2.openbanking.accelerator.common.config.OpenBankingConfigParser;
-import com.wso2.openbanking.accelerator.common.error.OpenBankingErrorCodes;
-import com.wso2.openbanking.accelerator.gateway.cache.OpenBankingIdempotencyCacheKey;
-import com.wso2.openbanking.accelerator.gateway.cache.OpenBankingIdempotencyValidationCache;
-import com.wso2.openbanking.accelerator.gateway.executor.core.OpenBankingGatewayExecutor;
-import com.wso2.openbanking.accelerator.gateway.executor.model.OBAPIRequestContext;
-import com.wso2.openbanking.accelerator.gateway.executor.model.OBAPIResponseContext;
-import com.wso2.openbanking.accelerator.gateway.executor.model.OpenBankingExecutorError;
-import com.wso2.openbanking.accelerator.gateway.util.GatewayConstants;
-import com.wso2.openbanking.accelerator.gateway.util.IdempotencyConstants;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.apimgt.common.gateway.dto.MsgInfoDTO;
-
-import java.io.IOException;
-import java.time.Duration;
-import java.time.OffsetDateTime;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Executor to handle Payment Idempotency.
- */
-public abstract class OpenBankingIdempotencyHandlingExecutor implements OpenBankingGatewayExecutor {
-
- private static final Log log = LogFactory.getLog(OpenBankingIdempotencyHandlingExecutor.class);
- private OpenBankingIdempotencyValidationCache openBankingIdempotencyValidationCache =
- OpenBankingIdempotencyValidationCache.getInstance();
- private OpenBankingConfigParser openBankingConfigParser = OpenBankingConfigParser.getInstance();
-
- /**
- * Method to handle pre request.
- *
- * @param obapiRequestContext OB request context object.
- */
- @Override
- public void preProcessRequest(OBAPIRequestContext obapiRequestContext) {
-
- }
-
- /**
- * Method to handle post request.
- *
- * @param obapiRequestContext OB request context object.
- */
- @Override
- public void postProcessRequest(OBAPIRequestContext obapiRequestContext) {
-
- // Checking if idempotency is enabled.
- if (!isIdempotencyEnabledFromConfig()) {
- return;
- }
-
- // Validating if the request is a valid idempotency available request.
- if (!isValidIdempotencyRequest(obapiRequestContext)) {
- return;
- }
-
- //Retrieve headers and payload
- Map requestHeaders = obapiRequestContext.getMsgInfo().getHeaders();
-
- //Retrieve consumer key from headers
- String consumerKey = obapiRequestContext.getApiRequestInfo().getConsumerKey();
- //Retrieve idempotency key from headers
- String idempotencyKey = requestHeaders.get(getIdempotencyKeyConstantFromConfig());
- //Retrieve context properties
- Map contextProps = obapiRequestContext.getContextProps();
-
- // Retrieve elected resources
- String resource = obapiRequestContext.getMsgInfo().getResource();
-
- //Construct cache keys for request and response using client Id and idempotency key
- String idempotencyCacheKey = consumerKey + "_" + resource + "_" + idempotencyKey;
-
- try {
- Map payloadMap = getPayloadFromRequest(obapiRequestContext);
-
- String payload;
- if (payloadMap.containsKey(IdempotencyConstants.PAYLOAD)) {
- payload = (String) payloadMap.get(IdempotencyConstants.PAYLOAD);
- } else {
- log.error("Error reading payload, " + IdempotencyConstants.PAYLOAD + " is not set.");
- return;
- }
-
- int httpStatus;
- if (payloadMap.containsKey(IdempotencyConstants.HTTP_STATUS)) {
- httpStatus = (int) payloadMap.get(IdempotencyConstants.HTTP_STATUS);
- } else {
- log.error("Error reading HTTP status, " + IdempotencyConstants.HTTP_STATUS + " is not set.");
- return;
- }
-
- Map cachedObjectMap = getPropertiesFromCache(idempotencyCacheKey);
- //Check whether the request exists in the cache
- if (!cachedObjectMap.isEmpty()) {
- log.debug("Handling idempotency through gateway");
-
- // previous result is present in cache, retrieving request from cache
- String cachedRequest = cachedObjectMap.get(GatewayConstants.REQUEST_CACHE_KEY);
- String createdTime = cachedObjectMap.get(GatewayConstants.CREATED_TIME_CACHE_KEY);
- //Check whether payload received is similar to the payload stored
- if (isJSONPayloadSimilar(cachedRequest, payload)) {
- log.debug("Payloads are similar for idempotent request");
- //Payloads are similar, hence checking whether request came within allowed time
- if (isRequestReceivedWithinAllowedTime(createdTime)) {
- log.debug("Idempotent request received within allowed time");
- //Retrieving the response from cache
- String cachedResponse = cachedObjectMap.get(GatewayConstants.RESPONSE_CACHE_KEY);
-
- //Setting payload as modified payload
- log.debug("Setting cached payload as the response");
- obapiRequestContext.setModifiedPayload(cachedResponse);
-
- //Setting Context Properties to return response without executing further
- contextProps.put(GatewayConstants.IS_RETURN_RESPONSE, GatewayConstants.TRUE);
- contextProps.put(GatewayConstants.MODIFIED_STATUS, String.valueOf(httpStatus));
- }
- } else {
- //Payloads are not similar, hence returning an error
- log.error(IdempotencyConstants.Error.EXECUTOR_IDEMPOTENCY_KEY_FRAUDULENT);
- obapiRequestContext.setError(true);
- obapiRequestContext.setErrors(handleIdempotencyErrors(obapiRequestContext,
- IdempotencyConstants.Error.EXECUTOR_IDEMPOTENCY_KEY_FRAUDULENT,
- IdempotencyConstants.Error.HEADER_INVALID));
- }
- } else {
- log.debug("Request is not found in cache, adding the request to cache.");
- //Since request is not in cache, adding the request to the cache against the idempotency key
- contextProps.put(GatewayConstants.REQUEST_CACHE_KEY, payload);
- }
- } catch (IOException e) {
- log.error(IdempotencyConstants.Error.EXECUTOR_IDEMPOTENCY_KEY_ERROR, e);
- obapiRequestContext.setError(true);
- obapiRequestContext.setErrors(handleIdempotencyErrors(obapiRequestContext,
- IdempotencyConstants.Error.EXECUTOR_IDEMPOTENCY_KEY_ERROR,
- IdempotencyConstants.Error.HEADER_INVALID));
- return;
- }
- //Adding idempotency key to the context properties
- contextProps.put(GatewayConstants.IDEMPOTENCY_KEY_CACHE_KEY, idempotencyKey);
- obapiRequestContext.setContextProps(contextProps);
- }
-
- /**
- * Method to handle pre response.
- *
- * @param obapiResponseContext OB response context object.
- */
- @Override
- public void preProcessResponse(OBAPIResponseContext obapiResponseContext) {
-
- }
-
- /**
- * Method to handle post response.
- *
- * @param obapiResponseContext OB response context object.
- */
- @Override
- public void postProcessResponse(OBAPIResponseContext obapiResponseContext) {
-
- // Checking if idempotency is enabled.
- if (!isIdempotencyEnabledFromConfig()) {
- return;
- }
-
- // Validating if the response is a valid idempotency available response.
- if (!isValidIdempotencyResponse(obapiResponseContext)) {
- return;
- }
-
- //Retrieving payload
- String responsePayload = obapiResponseContext.getResponsePayload();
- //Retrieve idempotency key from headers
- String consumerKey = obapiResponseContext.getApiRequestInfo().getConsumerKey();
- //Retrieve context properties
- Map contextProps = obapiResponseContext.getContextProps();
-
- MsgInfoDTO msgInfoDTO = obapiResponseContext.getMsgInfo();
-
- String idempotencyKey;
- if (msgInfoDTO.getHeaders().get(getIdempotencyKeyConstantFromConfig()) != null) {
- //Retrieve idempotency key from headers
- idempotencyKey = msgInfoDTO.getHeaders().get(getIdempotencyKeyConstantFromConfig());
- } else {
- //Retrieve idempotency key from context props if it does not exist as a header
- idempotencyKey = contextProps.get(GatewayConstants.IDEMPOTENCY_KEY_CACHE_KEY);
- }
-
- String createdTime = getCreatedTimeFromResponse(obapiResponseContext);
- if (createdTime == null) {
- log.error(IdempotencyConstants.Error.DATE_MISSING);
- return;
- }
-
- // Retrieve elected resources
- String resource = msgInfoDTO.getResource();
-
- //Construct cache keys for request and response using client Id and idempotency key
- String idempotencyCacheKey = consumerKey + "_" + resource + "_" + idempotencyKey;
-
- //Add response and created time to the cache
- HashMap cachedObject = getPropertiesFromCache(idempotencyCacheKey);
- if (contextProps.get(GatewayConstants.REQUEST_CACHE_KEY) != null) {
- cachedObject.put(GatewayConstants.REQUEST_CACHE_KEY, contextProps.get(GatewayConstants.REQUEST_CACHE_KEY));
- }
- cachedObject.put(GatewayConstants.RESPONSE_CACHE_KEY, responsePayload);
- cachedObject.put(GatewayConstants.CREATED_TIME_CACHE_KEY, createdTime);
-
- log.debug("Setting properties to cache");
- setPropertiesToCache(idempotencyCacheKey, cachedObject);
- }
-
- /**
- * Method to handle errors in Idempotency validation.
- *
- * @param obapiRequestContext obapiRequestContext.
- * @param message message.
- * @return Arraylist of OpenBankingExecutorError.
- */
- protected ArrayList handleIdempotencyErrors(OBAPIRequestContext obapiRequestContext,
- String message, String errorCode) {
-
- OpenBankingExecutorError error = new OpenBankingExecutorError(errorCode,
- IdempotencyConstants.Error.IDEMPOTENCY_HANDLE_ERROR, message,
- OpenBankingErrorCodes.BAD_REQUEST_CODE);
- ArrayList executorErrors = obapiRequestContext.getErrors();
- executorErrors.add(error);
- return executorErrors;
- }
-
- /**
- * Method to store properties to cache.
- *
- * @param key unique cache key.
- * @param idempotentDetails properties to store.
- */
- private void setPropertiesToCache(String key, HashMap idempotentDetails) {
-
- openBankingIdempotencyValidationCache.addToCache(
- OpenBankingIdempotencyCacheKey.of(key), idempotentDetails);
- }
-
- /**
- * Method to retrieve context properties from cache.
- *
- * @param key unique cache key.
- * @return context properties.
- */
- private HashMap getPropertiesFromCache(String key) {
-
- HashMap cachedObject = openBankingIdempotencyValidationCache.getFromCache(
- OpenBankingIdempotencyCacheKey.of(key));
- return cachedObject == null ? new HashMap<>() : cachedObject;
- }
-
- /**
- * Method to compare whether JSON payloads are equal.
- *
- * @param jsonString1 JSON payload retrieved from database
- * @param jsonString2 JSON payload received from current request
- * @return
- * @throws IOException
- */
- private boolean isJSONPayloadSimilar(String jsonString1, String jsonString2) throws IOException {
-
- JsonNode expectedNode = new ObjectMapper().readTree(jsonString1);
- JsonNode actualNode = new ObjectMapper().readTree(jsonString2);
- return expectedNode.equals(actualNode);
- }
-
- /**
- * Method to check whether difference between two dates is less than the configured time.
- *
- * @param createdTime Created Time of the request
- * @return
- */
- protected boolean isRequestReceivedWithinAllowedTime(String createdTime) {
-
- if (createdTime == null) {
- return true;
- }
- String allowedTimeDuration = (String) openBankingConfigParser.getConfiguration()
- .get(IdempotencyConstants.IDEMPOTENCY_ALLOWED_TIME);
- if (allowedTimeDuration != null) {
- OffsetDateTime createdDate = OffsetDateTime.parse(createdTime);
- OffsetDateTime currDate = OffsetDateTime.now(createdDate.getOffset());
-
- long diffInHours = Duration.between(createdDate, currDate).toMinutes();
- return diffInHours <= Long.parseLong(allowedTimeDuration);
- } else {
- log.error("Idempotency Allowed duration is null");
- return false;
- }
- }
-
- /**
- * Method to check whether Idempotency handling is required.
- *
- * @return True if idempotency is required, else False.
- */
- private boolean isIdempotencyEnabledFromConfig() {
-
- String isIdempotencyEnabled = (String) openBankingConfigParser.getConfiguration()
- .get(IdempotencyConstants.IDEMPOTENCY_IS_ENABLED);
-
- return Boolean.parseBoolean(isIdempotencyEnabled);
- }
-
- /**
- * Method to get the Idempotency Key from the config.
- *
- * @return idempotency key.
- */
- protected String getIdempotencyKeyConstantFromConfig() {
-
- return (String) openBankingConfigParser.getConfiguration()
- .get(IdempotencyConstants.IDEMPOTENCY_KEY_HEADER);
- }
-
- /**
- * Method to get Created time from response.
- *
- * @param obapiResponseContext obapiResponseContext.
- * @return created time.
- */
- public abstract String getCreatedTimeFromResponse(OBAPIResponseContext obapiResponseContext);
-
- /**
- * Method to get payload from request.
- *
- * @param obapiRequestContext obapiRequestContext.
- * @return Map containing the payload and the http status.
- */
- public abstract Map getPayloadFromRequest(OBAPIRequestContext obapiRequestContext);
-
- /**
- * Method to check if the request is a valid idempotency request.
- *
- * @param obapiRequestContext obapiRequestContext.
- * @return True if the request is valid, False if not.
- */
- public abstract boolean isValidIdempotencyRequest(OBAPIRequestContext obapiRequestContext);
-
- /**
- * Method to check if the method is a valid idempotency response.
- *
- * @param obapiResponseContext obapiResponseContext.
- * @return True if the response is valid, False if not.
- */
- public abstract boolean isValidIdempotencyResponse(OBAPIResponseContext obapiResponseContext);
-}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/java/com/wso2/openbanking/accelerator/gateway/executor/idempotency/OpenBankingIdempotencyHandlingExecutorImpl.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/java/com/wso2/openbanking/accelerator/gateway/executor/idempotency/OpenBankingIdempotencyHandlingExecutorImpl.java
deleted file mode 100644
index d6feeb91..00000000
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/java/com/wso2/openbanking/accelerator/gateway/executor/idempotency/OpenBankingIdempotencyHandlingExecutorImpl.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
- *
- * WSO2 LLC. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package com.wso2.openbanking.accelerator.gateway.executor.idempotency;
-
-import com.wso2.openbanking.accelerator.gateway.executor.model.OBAPIRequestContext;
-import com.wso2.openbanking.accelerator.gateway.executor.model.OBAPIResponseContext;
-import com.wso2.openbanking.accelerator.gateway.util.IdempotencyConstants;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpStatus;
-import org.wso2.carbon.apimgt.common.gateway.dto.MsgInfoDTO;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-/**
- * OpenBankingIdempotencyHandlingExecutorImpl.
- */
-public class OpenBankingIdempotencyHandlingExecutorImpl extends OpenBankingIdempotencyHandlingExecutor {
-
- private static final Log log = LogFactory.getLog(OpenBankingIdempotencyHandlingExecutorImpl.class);
-
-
- @Override
- public String getCreatedTimeFromResponse(OBAPIResponseContext obapiResponseContext) {
- MsgInfoDTO msgInfoDTO = obapiResponseContext.getMsgInfo();
- String createdTime = null;
- if (msgInfoDTO.getHeaders().get("CreatedTime") != null) {
- //Retrieve response created time from headers
- createdTime = msgInfoDTO.getHeaders().get("CreatedTime");
- }
- return createdTime;
- }
-
- @Override
- public Map getPayloadFromRequest(OBAPIRequestContext obapiRequestContext) {
- Map map = new HashMap<>();
- map.put(IdempotencyConstants.PAYLOAD, obapiRequestContext.getRequestPayload());
- map.put(IdempotencyConstants.HTTP_STATUS, HttpStatus.SC_CREATED);
- return map;
- }
-
- @Override
- public boolean isValidIdempotencyRequest(OBAPIRequestContext obapiRequestContext) {
- return true;
- }
-
- @Override
- public boolean isValidIdempotencyResponse(OBAPIResponseContext obapiResponseContext) {
- return true;
- }
-}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/java/com/wso2/openbanking/accelerator/gateway/executor/idempotency/OpenBankingIdempotencyHandlingExecutorTests.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/java/com/wso2/openbanking/accelerator/gateway/executor/idempotency/OpenBankingIdempotencyHandlingExecutorTests.java
deleted file mode 100644
index 6af805f0..00000000
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/java/com/wso2/openbanking/accelerator/gateway/executor/idempotency/OpenBankingIdempotencyHandlingExecutorTests.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/**
- * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
- *
- * WSO2 LLC. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package com.wso2.openbanking.accelerator.gateway.executor.idempotency;
-
-import com.wso2.openbanking.accelerator.common.config.OpenBankingConfigParser;
-import com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedCacheConstants;
-import com.wso2.openbanking.accelerator.common.distributed.caching.OpenBankingDistributedMember;
-import com.wso2.openbanking.accelerator.gateway.cache.OpenBankingIdempotencyCacheKey;
-import com.wso2.openbanking.accelerator.gateway.cache.OpenBankingIdempotencyValidationCache;
-import com.wso2.openbanking.accelerator.gateway.executor.model.OBAPIRequestContext;
-import com.wso2.openbanking.accelerator.gateway.executor.model.OBAPIResponseContext;
-import com.wso2.openbanking.accelerator.gateway.util.GatewayConstants;
-import com.wso2.openbanking.accelerator.gateway.util.IdempotencyConstants;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PowerMockIgnore;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.testng.PowerMockTestCase;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-import org.wso2.carbon.apimgt.common.gateway.dto.APIRequestInfoDTO;
-import org.wso2.carbon.apimgt.common.gateway.dto.MsgInfoDTO;
-
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.mockito.Mockito.when;
-import static org.powermock.api.mockito.PowerMockito.mockStatic;
-
-/**
- ** Tests class for OpenBankingIdempotencyHandlingExecutor.
- */
-@PowerMockIgnore({"jdk.internal.reflect.*", "javax.management.*"})
-@PrepareForTest({OpenBankingConfigParser.class})
-public class OpenBankingIdempotencyHandlingExecutorTests extends PowerMockTestCase {
-
- @Mock
- OBAPIRequestContext obapiRequestContextMock;
-
- @Mock
- OBAPIResponseContext obapiResponseContextMock;
-
- @Mock
- MsgInfoDTO msgInfoDTO;
-
- @Mock
- APIRequestInfoDTO apiRequestInfoDTO;
-
- @Mock
- OpenBankingConfigParser openBankingConfigParser;
-
- String sampleIdempotencyKey = "a5ff9494-2a15-48f9-8ab4-05a10b91215b";
- String sampleConsumerKey = "dummykey";
- String sampleElectedResource = "/sampleElectedResource/1234";
- String sampleResponsePayload = "{\"transactionStatus\":\"RCVD\",\"chosenScaMethod\":" +
- "[{\"name\":\"SMS OTP on Mobile\"," +
- "\"authenticationType\":\"SMS_OTP\",\"explanation\":\"SMS based one time password\"," +
- "\"authenticationMethodId\":\"sms-otp\"}],\"_links\":{\"scaStatus\":" +
- "{\"href\":\"/v1/payments/sepa-credit-transfers/beecd66c-82ae-4ac8-9c04-9bd7c886d4a4/" +
- "authorisations/1d5b6e3b-2180-4b4f-bb8c-054c597cb4e3\"},\"scaOAuth\":" +
- "{\"href\":\"https://localhost:8243/.well-known/openid-configuration\"}," +
- "\"self\":{\"href\":\"/v/payments/sepa-credit-transfers/beecd66c-82ae-4ac8-9c04-9bd7c886d4a4\"}," +
- "\"status\":{\"href\":\"/v1/payments/sepa-credit-transfers/beecd66c-82ae-4ac8-9c04-9bd7c886d4a4" +
- "/status\"}},\"paymentId\":\"beecd66c-82ae-4ac8-9c04-9bd7c886d4a4\"}";
-
- DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
- ZonedDateTime zdt = ZonedDateTime.now();
- String sampleCreatedTime = dtf.format(zdt);
-
- String idempotencyCacheKeyHeader = "x-Idempotency-Key";
-
- @BeforeClass
- public void initClass() {
-
- MockitoAnnotations.initMocks(this);
- }
-
- @Test(priority = 1)
- public void testPostProcessResponse() {
-
- mockStatic(OpenBankingConfigParser.class);
- when(OpenBankingConfigParser.getInstance()).thenReturn(openBankingConfigParser);
-
- Map configuration = new HashMap<>();
- configuration.putAll(getDistributedCachingMockConfigurations());
- configuration.putAll(getIdempotencyMockConfigurations());
- Mockito.when(openBankingConfigParser.getConfiguration()).thenReturn(configuration);
-
- PowerMockito.mockStatic(OpenBankingConfigParser.class);
- PowerMockito.when(OpenBankingConfigParser.getInstance())
- .thenReturn(openBankingConfigParser);
-
- // Mocking response payload
- when(obapiResponseContextMock.getResponsePayload()).thenReturn(sampleResponsePayload);
-
- // Mocking consumer key
- when(obapiResponseContextMock.getApiRequestInfo()).thenReturn(apiRequestInfoDTO);
- when(apiRequestInfoDTO.getConsumerKey()).thenReturn(sampleConsumerKey);
-
- // Mocking context props
- Map contextProps = new HashMap<>();
- contextProps.put(GatewayConstants.REQUEST_CACHE_KEY, sampleResponsePayload);
- contextProps.put(GatewayConstants.IDEMPOTENCY_KEY_CACHE_KEY, sampleIdempotencyKey);
- when(obapiResponseContextMock.getContextProps()).thenReturn(contextProps);
-
- // Mocking response headers
- when(obapiResponseContextMock.getMsgInfo()).thenReturn(msgInfoDTO);
- Map responseHeaders = new HashMap<>();
- responseHeaders.put(idempotencyCacheKeyHeader, sampleIdempotencyKey);
- responseHeaders.put("CreatedTime", sampleCreatedTime);
- when(msgInfoDTO.getHeaders()).thenReturn(responseHeaders);
-
- // Mocking elected resource
- when(msgInfoDTO.getResource()).thenReturn(sampleElectedResource);
-
- OpenBankingIdempotencyHandlingExecutorImpl openBankingIdempotencyHandlingExecutorImpl =
- new OpenBankingIdempotencyHandlingExecutorImpl();
- openBankingIdempotencyHandlingExecutorImpl.postProcessResponse(obapiResponseContextMock);
-
- String cacheKey = sampleConsumerKey + "_" + sampleElectedResource + "_" + sampleIdempotencyKey;
- HashMap expectedFromCache = new HashMap<>();
- expectedFromCache.put(GatewayConstants.REQUEST_CACHE_KEY, sampleResponsePayload);
- expectedFromCache.put(GatewayConstants.RESPONSE_CACHE_KEY, sampleResponsePayload);
- expectedFromCache.put(GatewayConstants.CREATED_TIME_CACHE_KEY, sampleCreatedTime);
-
- HashMap fromCache = OpenBankingIdempotencyValidationCache.getInstance()
- .getFromCache(OpenBankingIdempotencyCacheKey.of(cacheKey));
-
- Assert.assertEquals(fromCache, expectedFromCache);
- }
-
- @Test(priority = 2)
- public void testPostProcessRequest() {
-
- mockStatic(OpenBankingConfigParser.class);
- when(OpenBankingConfigParser.getInstance()).thenReturn(openBankingConfigParser);
-
- Map configuration = new HashMap<>();
- configuration.putAll(getDistributedCachingMockConfigurations());
- configuration.putAll(getIdempotencyMockConfigurations());
- Mockito.when(openBankingConfigParser.getConfiguration()).thenReturn(configuration);
-
- PowerMockito.mockStatic(OpenBankingConfigParser.class);
- PowerMockito.when(OpenBankingConfigParser.getInstance())
- .thenReturn(openBankingConfigParser);
-
- when(obapiRequestContextMock.getRequestPayload()).thenReturn(sampleResponsePayload);
- // Mocking request headers
- when(obapiRequestContextMock.getMsgInfo()).thenReturn(msgInfoDTO);
- Map requestHeaders = new HashMap<>();
- requestHeaders.put(idempotencyCacheKeyHeader, sampleIdempotencyKey);
- when(msgInfoDTO.getHeaders()).thenReturn(requestHeaders);
-
- // Mocking elected resource
- when(msgInfoDTO.getResource()).thenReturn(sampleElectedResource);
-
- // Mocking consumer key
- when(obapiRequestContextMock.getApiRequestInfo()).thenReturn(apiRequestInfoDTO);
- when(apiRequestInfoDTO.getConsumerKey()).thenReturn(sampleConsumerKey);
-
- OpenBankingIdempotencyHandlingExecutorImpl openBankingIdempotencyHandlingExecutorImpl =
- new OpenBankingIdempotencyHandlingExecutorImpl();
- openBankingIdempotencyHandlingExecutorImpl.postProcessRequest(obapiRequestContextMock);
-
- }
-
- private Map getDistributedCachingMockConfigurations() {
-
- Map configuration = new HashMap<>();
-
- configuration.put(OpenBankingDistributedCacheConstants.ENABLED, "true");
- configuration.put(OpenBankingDistributedCacheConstants.HOST_NAME, "localhost");
- configuration.put(OpenBankingDistributedCacheConstants.PORT, "5721");
- configuration.put(OpenBankingDistributedCacheConstants.DISCOVERY_MECHANISM, "Multicast");
- configuration.put(OpenBankingDistributedCacheConstants.MULTICAST_GROUP, "224.2.2.3");
- configuration.put(OpenBankingDistributedCacheConstants.MULTICAST_PORT, "54321");
- ArrayList interfaces = new ArrayList<>();
- interfaces.add("192.168.1.100-110");
- configuration.put(OpenBankingDistributedCacheConstants.TRUSTED_INTERFACES, interfaces);
- configuration.put(OpenBankingDistributedCacheConstants.HAZELCAST_PROPERTY_MAX_HEARTBEAT, "600");
- configuration.put(OpenBankingDistributedCacheConstants.HAZELCAST_PROPERTY_MAX_MASTER_CONFIRMATION, "900");
- configuration.put(OpenBankingDistributedCacheConstants.HAZELCAST_PROPERTY_MERGE_FIRST_RUN_DELAY, "60");
- configuration.put(OpenBankingDistributedCacheConstants.HAZELCAST_PROPERTY_MERGE_NEXT_RUN_DELAY, "30");
- configuration.put(OpenBankingDistributedCacheConstants.PROPERTY_LOGGING_TYPE, "none");
-
- return configuration;
- }
-
- private Map getIdempotencyMockConfigurations() {
-
- Map configuration = new HashMap<>();
- configuration.put(IdempotencyConstants.IDEMPOTENCY_IS_ENABLED, "true");
- configuration.put(IdempotencyConstants.IDEMPOTENCY_CACHE_TIME_TO_LIVE, "1440");
- configuration.put(IdempotencyConstants.IDEMPOTENCY_KEY_HEADER, idempotencyCacheKeyHeader);
- configuration.put(IdempotencyConstants.IDEMPOTENCY_ALLOWED_TIME, "24");
-
- return configuration;
- }
-
- @AfterClass
- public void after() {
-
- OpenBankingDistributedMember.of().shutdown();
- }
-
-}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/java/com/wso2/openbanking/accelerator/gateway/executor/impl/error/handler/OBDefaultErrorHandlerTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/java/com/wso2/openbanking/accelerator/gateway/executor/impl/error/handler/OBDefaultErrorHandlerTest.java
new file mode 100644
index 00000000..d7921b2e
--- /dev/null
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/java/com/wso2/openbanking/accelerator/gateway/executor/impl/error/handler/OBDefaultErrorHandlerTest.java
@@ -0,0 +1,106 @@
+/**
+ * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.openbanking.accelerator.gateway.executor.impl.error.handler;
+
+import com.wso2.openbanking.accelerator.gateway.executor.model.OBAPIRequestContext;
+import com.wso2.openbanking.accelerator.gateway.executor.model.OBAPIResponseContext;
+import com.wso2.openbanking.accelerator.gateway.executor.model.OpenBankingExecutorError;
+import org.mockito.Mockito;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+/**
+ * Test class for OBDefaultErrorHandler.
+ */
+public class OBDefaultErrorHandlerTest {
+
+ Map contextProps = new HashMap<>();
+
+ @Test
+ public void testPreRequestFlow() {
+
+ OBAPIRequestContext obapiRequestContext = Mockito.mock(OBAPIRequestContext.class);
+ Mockito.when(obapiRequestContext.isError()).thenReturn(true);
+ Mockito.when(obapiRequestContext.getErrors()).thenReturn(getErrorList());
+ Mockito.when(obapiRequestContext.getContextProps()).thenReturn(contextProps);
+ Mockito.when(obapiRequestContext.getAnalyticsData()).thenReturn(new HashMap<>());
+
+ OBDefaultErrorHandler commonReportingDataExecutor = Mockito.spy(OBDefaultErrorHandler.class);
+ commonReportingDataExecutor.preProcessRequest(obapiRequestContext);
+ verify(obapiRequestContext, times(0)).setError(false);
+ }
+
+ @Test
+ public void testPostRequestFlow() {
+
+ OBAPIRequestContext obapiRequestContext = Mockito.mock(OBAPIRequestContext.class);
+ Mockito.when(obapiRequestContext.isError()).thenReturn(true);
+ Mockito.when(obapiRequestContext.getErrors()).thenReturn(getErrorList());
+ Mockito.when(obapiRequestContext.getContextProps()).thenReturn(contextProps);
+ Mockito.when(obapiRequestContext.getAnalyticsData()).thenReturn(new HashMap<>());
+
+ OBDefaultErrorHandler commonReportingDataExecutor = Mockito.spy(OBDefaultErrorHandler.class);
+ commonReportingDataExecutor.postProcessRequest(obapiRequestContext);
+ verify(obapiRequestContext, times(0)).setError(false);
+ }
+
+ @Test
+ public void testPreResponseFlow() {
+
+ OBAPIResponseContext obapiResponseContext = Mockito.mock(OBAPIResponseContext.class);
+ Mockito.when(obapiResponseContext.isError()).thenReturn(true);
+ Mockito.when(obapiResponseContext.getErrors()).thenReturn(getErrorList());
+ Mockito.when(obapiResponseContext.getContextProps()).thenReturn(contextProps);
+ Mockito.when(obapiResponseContext.getAnalyticsData()).thenReturn(new HashMap<>());
+
+ OBDefaultErrorHandler commonReportingDataExecutor = Mockito.spy(OBDefaultErrorHandler.class);
+ commonReportingDataExecutor.preProcessResponse(obapiResponseContext);
+ verify(obapiResponseContext, times(0)).setError(false);
+ }
+
+ @Test
+ public void testPostResponseFlow() {
+
+ OBAPIResponseContext obapiResponseContext = Mockito.mock(OBAPIResponseContext.class);
+ Mockito.when(obapiResponseContext.isError()).thenReturn(true);
+ Mockito.when(obapiResponseContext.getErrors()).thenReturn(getErrorList());
+ Mockito.when(obapiResponseContext.getContextProps()).thenReturn(contextProps);
+ Mockito.when(obapiResponseContext.getAnalyticsData()).thenReturn(new HashMap<>());
+
+ OBDefaultErrorHandler commonReportingDataExecutor = Mockito.spy(OBDefaultErrorHandler.class);
+ commonReportingDataExecutor.postProcessResponse(obapiResponseContext);
+ verify(obapiResponseContext, times(0)).setError(false);
+ }
+
+ private ArrayList getErrorList() {
+
+ OpenBankingExecutorError error = new OpenBankingExecutorError("400", "Invalid Request",
+ "Mandatory parameter is missing", "400");
+
+ ArrayList errors = new ArrayList<>();
+ errors.add(error);
+ return errors;
+ }
+}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/resources/testng.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/resources/testng.xml
index 723ddc92..49169106 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/resources/testng.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/resources/testng.xml
@@ -36,6 +36,7 @@
+
@@ -57,11 +58,6 @@
-
-
-
-
-
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidationResult.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidationResult.java
new file mode 100644
index 00000000..5a09f8ed
--- /dev/null
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidationResult.java
@@ -0,0 +1,72 @@
+/**
+ * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.openbanking.accelerator.consent.extensions.common.idempotency;
+
+import com.wso2.openbanking.accelerator.consent.mgt.dao.models.DetailedConsentResource;
+
+/**
+ * Class to hold idempotency validation result.
+ */
+public class IdempotencyValidationResult {
+
+ private boolean isIdempotent;
+ private boolean isValid;
+ private DetailedConsentResource consent;
+ private String consentId;
+
+ public IdempotencyValidationResult(boolean isIdempotent, boolean isValid, DetailedConsentResource consent,
+ String consentId) {
+ this.isIdempotent = isIdempotent;
+ this.isValid = isValid;
+ this.consent = consent;
+ this.consentId = consentId;
+ }
+
+ public boolean isIdempotent() {
+ return isIdempotent;
+ }
+
+ public void setIsIdempotent(boolean isIdempotent) {
+ this.isIdempotent = isIdempotent;
+ }
+
+ public boolean isValid() {
+ return isValid;
+ }
+
+ public void setValid(boolean isValid) {
+ this.isValid = isValid;
+ }
+
+ public DetailedConsentResource getConsent() {
+ return consent;
+ }
+
+ public void setConsent(DetailedConsentResource consent) {
+ this.consent = consent;
+ }
+
+ public String getConsentId() {
+ return consentId;
+ }
+
+ public void setConsentID(String consentId) {
+ this.consentId = consentId;
+ }
+}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
new file mode 100644
index 00000000..eabf32ad
--- /dev/null
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
@@ -0,0 +1,205 @@
+/**
+ * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.openbanking.accelerator.consent.extensions.common.idempotency;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.wso2.openbanking.accelerator.common.config.OpenBankingConfigParser;
+import com.wso2.openbanking.accelerator.common.exception.ConsentManagementException;
+import com.wso2.openbanking.accelerator.consent.extensions.internal.ConsentExtensionsDataHolder;
+import com.wso2.openbanking.accelerator.consent.mgt.dao.models.DetailedConsentResource;
+import com.wso2.openbanking.accelerator.consent.mgt.service.ConsentCoreService;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.time.Duration;
+import java.time.OffsetDateTime;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * Class to handle idempotency related operations.
+ */
+public class IdempotencyValidator {
+
+ private static final Log log = LogFactory.getLog(IdempotencyValidator.class);
+ private static final OpenBankingConfigParser parser = OpenBankingConfigParser.getInstance();
+ private static final ConsentCoreService consentCoreService = ConsentExtensionsDataHolder.getInstance()
+ .getConsentCoreService();
+ public static final String IDEMPOTENCY_IS_ENABLED = "Consent.Idempotency.IsEnabled";
+ private static final String IDEMPOTENCY_ALLOWED_TIME = "Consent.Idempotency.AllowedTimeDuration";
+
+ public IdempotencyValidator() {
+ }
+
+ /**
+ * Method to check whether the request is idempotent.
+ * This method will first check whether idempotency validation is enabled. Then it will check whether the
+ * idempotency key exists in the database and whether the request is received within the allowed time.
+ *
+ * @param idempotencyKeyName Idempotency Key Name
+ * @param idempotencyKeyValue Idempotency Key Value
+ * @param request Request Payload
+ * @return IdempotencyValidationResult
+ */
+ public static IdempotencyValidationResult validateIdempotency(String idempotencyKeyName, String idempotencyKeyValue,
+ String request) {
+ if (Boolean.parseBoolean((String) parser.getConfiguration().get(IDEMPOTENCY_IS_ENABLED))) {
+ if (idempotencyKeyValue == null || request.isEmpty()) {
+ log.debug("Idempotency Key Value or Request is empty. Hence cannot proceed with " +
+ "idempotency validation");
+ return new IdempotencyValidationResult(false, false, null, null);
+ }
+ try {
+ ArrayList consentIds = getConsentIdsFromIdempotencyKey(idempotencyKeyName,
+ idempotencyKeyValue);
+ if (isIdempotencyKeyExists(consentIds)) {
+ log.debug("Idempotency Key exists in the database. Hence this is an idempotent request");
+ for (String consentId : consentIds) {
+ DetailedConsentResource consentRequest = consentCoreService.getDetailedConsent(consentId);
+ if (consentRequest != null) {
+ if (isJSONPayloadSimilar(consentRequest.getReceipt(), request)) {
+ if (isRequestReceivedWithinAllowedTime(consentRequest.getCreatedTime())) {
+ log.debug("Payloads are similar and request received within allowed time." +
+ " Hence this is a valid idempotent request");
+ return new IdempotencyValidationResult(true, true,
+ consentRequest, consentId);
+ } else {
+ log.debug("Payloads are similar and request is not within allowed time." +
+ " Hence this is not a valid idempotent request");
+ return new IdempotencyValidationResult(true, false, null, null);
+ }
+ } else {
+ log.debug("Payloads are not similar, Hence this is not a valid idempotent " +
+ "request");
+ return new IdempotencyValidationResult(true, false, null, null);
+ }
+ } else {
+ log.debug("No consent details found for the consent ID, Hence this is not a " +
+ "valid idempotent request");
+ return new IdempotencyValidationResult(true, false, null, null);
+ }
+ }
+ }
+ } catch (IOException | ConsentManagementException e) {
+ log.error("Error occurred while comparing JSON payloads", e);
+ }
+ }
+ return new IdempotencyValidationResult(false, false, null, null);
+ }
+
+ /**
+ * Method to store the idempotency key in the database.
+ *
+ * @param consentId Consent ID
+ * @param idempotencyKeyName Idempotency Key Name
+ * @param idempotencyKeyValue Idempotency Key Value
+ * @return Whether the idempotency key is stored in the database
+ * @throws ConsentManagementException If an error occurs while storing the idempotency key
+ */
+ public static boolean storeIdempotencyKeyInAttributes(String consentId, String idempotencyKeyName,
+ String idempotencyKeyValue) throws ConsentManagementException {
+
+ return consentCoreService.storeConsentAttributes(consentId, Map.of(idempotencyKeyName, idempotencyKeyValue));
+ }
+
+ /**
+ * Method to retrieve the consent ids that have the idempotency key name and value as attribute.
+ *
+ * @param idempotencyKeyName Idempotency Key Name
+ * @param idempotencyKeyValue Idempotency Key Value
+ * @return List of consent ids
+ */
+ private static ArrayList getConsentIdsFromIdempotencyKey(String idempotencyKeyName,
+ String idempotencyKeyValue) {
+ try {
+ return consentCoreService.getConsentIdByConsentAttributeNameAndValue(
+ idempotencyKeyName, idempotencyKeyValue);
+ } catch (ConsentManagementException e) {
+ log.debug("No consent ids found for the idempotency key value");
+ return new ArrayList<>();
+ }
+ }
+
+ /**
+ * Method to check whether the idempotency key exists in the database.
+ *
+ * @param consentIds List of consentIds
+ * @return Whether the idempotency key exists
+ */
+ private static boolean isIdempotencyKeyExists(ArrayList consentIds) {
+ return consentIds.size() > 0;
+ }
+
+ /**
+ * Method to compare whether JSON payloads are equal.
+ *
+ * @param jsonString1 JSON payload retrieved from database
+ * @param jsonString2 JSON payload received from current request
+ * @return Whether JSON payloads are equal
+ * @throws IOException If an error occurs while comparing JSON payloads
+ */
+ private static boolean isJSONPayloadSimilar(String jsonString1, String jsonString2) throws IOException {
+
+ JsonNode expectedNode = new ObjectMapper().readTree(jsonString1);
+ JsonNode actualNode = new ObjectMapper().readTree(jsonString2);
+ return expectedNode.equals(actualNode);
+ }
+
+ /**
+ * Method to check whether difference between two dates is less than the configured time.
+ *
+ * @param createdTime Created Time of the request
+ * @return Whether the request is received within allowed time
+ */
+ protected static boolean isRequestReceivedWithinAllowedTime(long createdTime) {
+
+ if (createdTime == 0L) {
+ return false;
+ }
+ String allowedTimeDuration = (String) parser.getConfiguration()
+ .get(IDEMPOTENCY_ALLOWED_TIME);
+ if (allowedTimeDuration != null) {
+ OffsetDateTime createdDate = OffsetDateTime.parse(convertToISO8601(createdTime));
+ OffsetDateTime currDate = OffsetDateTime.now(createdDate.getOffset());
+
+ long diffInHours = Duration.between(createdDate, currDate).toMinutes();
+ return diffInHours <= Long.parseLong(allowedTimeDuration);
+ } else {
+ log.error("Idempotency Allowed duration is null");
+ return false;
+ }
+ }
+
+ /**
+ * Convert long date values to ISO 8601 format.
+ * @param dateValue Date value
+ * @return ISO 8601 formatted date
+ */
+ public static String convertToISO8601(long dateValue) {
+
+ DateFormat simple = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
+ Date simpleDateVal = new Date(dateValue * 1000);
+ return simple.format(simpleDateVal);
+ }
+}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
index 33e724c8..0e175dee 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
@@ -80,6 +80,11 @@
powermock-module-testngtest
+
+ com.wso2.openbanking.accelerator
+ com.wso2.openbanking.accelerator.consent.extensions
+ test
+
diff --git a/pom.xml b/pom.xml
index 9479e7a6..e4aaab44 100644
--- a/pom.xml
+++ b/pom.xml
@@ -487,11 +487,6 @@
javax.servlet${equinox.javax.servlet.version}
-
- com.hazelcast
- hazelcast
- ${com.hazelcast.hazelcast.version}
- org.jacoco
@@ -792,7 +787,6 @@
1.10.14.7.33.1.0
- 5.0.21.0.0.wso2v31.12.01.2.0.wso2v1
From b1bc71cb10c22d6b950203035b9f4e56cc05f9eb Mon Sep 17 00:00:00 2001
From: Ashirwada
Date: Mon, 4 Mar 2024 10:33:46 +0530
Subject: [PATCH 066/281] Moving Idempotency Validation to consent management
component
---
.../accelerator/common/test/util/SecurityUtilsTest.java | 2 +-
.../impl/error/handler/OBDefaultErrorHandlerTest.java | 2 +-
.../common/idempotency/IdempotencyValidationResult.java | 2 +-
.../extensions/common/idempotency/IdempotencyValidator.java | 2 +-
.../com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml | 5 -----
5 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/SecurityUtilsTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/SecurityUtilsTest.java
index d15625b0..a587f722 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/SecurityUtilsTest.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/SecurityUtilsTest.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/java/com/wso2/openbanking/accelerator/gateway/executor/impl/error/handler/OBDefaultErrorHandlerTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/java/com/wso2/openbanking/accelerator/gateway/executor/impl/error/handler/OBDefaultErrorHandlerTest.java
index d7921b2e..810e7b59 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/java/com/wso2/openbanking/accelerator/gateway/executor/impl/error/handler/OBDefaultErrorHandlerTest.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/java/com/wso2/openbanking/accelerator/gateway/executor/impl/error/handler/OBDefaultErrorHandlerTest.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidationResult.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidationResult.java
index 5a09f8ed..cbf6493d 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidationResult.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidationResult.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
index eabf32ad..947f93d4 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
index 0e175dee..33e724c8 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
@@ -80,11 +80,6 @@
powermock-module-testngtest
-
- com.wso2.openbanking.accelerator
- com.wso2.openbanking.accelerator.consent.extensions
- test
-
From 86bba0f6516f0a6c6efca02a6c035915f4bcfac9 Mon Sep 17 00:00:00 2001
From: Ashirwada
Date: Mon, 4 Mar 2024 10:55:13 +0530
Subject: [PATCH 067/281] Moving Idempotency Validation to consent management
component
---
.../pom.xml | 1 +
.../common/test/OBConfigParserTests.java | 21 +++++++++++++++++++
.../src/test/resources/open-banking.xml | 5 ++++-
3 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
index 1e7e1927..ae4ed2c1 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
@@ -179,6 +179,7 @@
**/JDBCPersistenceManager.class**/CertValidationErrors.class**/JDBCRetentionDataPersistenceManager.class
+ **/*Type*/**
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/OBConfigParserTests.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/OBConfigParserTests.java
index a4b542b2..44d6d038 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/OBConfigParserTests.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/OBConfigParserTests.java
@@ -425,6 +425,8 @@ public void testIsNonErrorDisputeDataPublishingEnabled() {
Assert.assertTrue(isEnabled);
}
+
+ @Test (priority = 33)
public void testRealtimeEventNotificationConfigs() {
String dummyConfigFile = absolutePathForTestResources + "/open-banking.xml";
OpenBankingConfigParser openBankingConfigParser = OpenBankingConfigParser.getInstance(dummyConfigFile);
@@ -446,4 +448,23 @@ public void testRealtimeEventNotificationConfigs() {
}
+ @Test (priority = 34)
+ public void testIsConsentAmendmentHistoryEnabled() {
+
+ String dummyConfigFile = absolutePathForTestResources + "/open-banking.xml";
+ boolean isEnabled = OpenBankingConfigParser.getInstance(dummyConfigFile)
+ .isConsentAmendmentHistoryEnabled();
+
+ Assert.assertTrue(isEnabled);
+ }
+
+ @Test (priority = 35)
+ public void testGetOBKeyManagerExtensionImpl() {
+
+ String dummyConfigFile = absolutePathForTestResources + "/open-banking.xml";
+ String className = OpenBankingConfigParser.getInstance(dummyConfigFile)
+ .getOBKeyManagerExtensionImpl();
+
+ Assert.assertEquals(className, "com.wso2.openbanking.accelerator.keymanager.OBKeyManagerImpl");
+ }
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/resources/open-banking.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/resources/open-banking.xml
index 248c38a6..a3dbb816 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/resources/open-banking.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/resources/open-banking.xml
@@ -156,6 +156,9 @@
+
+ true
+
@@ -207,7 +210,7 @@
-
+ com.wso2.openbanking.accelerator.keymanager.OBKeyManagerImpl
From acc05a485663ea7439e2bd511e0f224218cd30e2 Mon Sep 17 00:00:00 2001
From: Rivindu
Date: Mon, 4 Mar 2024 14:06:19 +0530
Subject: [PATCH 068/281] Move certificate expiry check method to common module
---
.../common/util/CertificateUtils.java | 19 +++++++++++++++++++
.../test/util/CertificateUtilsTest.java | 14 ++++++++++++++
.../common/test/util/CommonTestUtil.java | 12 ++++++++++++
.../CertRevocationValidationExecutor.java | 3 ++-
.../util/CertificateValidationUtils.java | 12 ------------
.../CertRevocationValidationExecutorTest.java | 3 ++-
6 files changed, 49 insertions(+), 14 deletions(-)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/CertificateUtils.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/CertificateUtils.java
index e81f4109..ca883b2f 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/CertificateUtils.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/CertificateUtils.java
@@ -82,4 +82,23 @@ private static String removeIllegalBase64Characters(String value) {
// remove spaces, \r, \\r, \n, \\n, ], [ characters from certificate string
return value.replaceAll("\\\\r|\\\\n|\\r|\\n|\\[|]| ", StringUtils.EMPTY);
}
+
+ /**
+ * Check whether the certificate is expired.
+ *
+ * @param peerCertificate the certificate to be checked
+ * @return true if the certificate is expired
+ */
+ public static boolean isExpired(X509Certificate peerCertificate) {
+ try {
+ peerCertificate.checkValidity();
+ } catch (CertificateException e) {
+ log.error("Certificate with the serial number " +
+ peerCertificate.getSerialNumber() + " issued by the CA " +
+ peerCertificate.getIssuerDN().toString() + " is expired. Caused by, " + e.getMessage());
+ return true;
+ }
+ return false;
+ }
+
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/CertificateUtilsTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/CertificateUtilsTest.java
index 3d933d28..3cfb2c49 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/CertificateUtilsTest.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/CertificateUtilsTest.java
@@ -21,6 +21,7 @@
import com.wso2.openbanking.accelerator.common.exception.OpenBankingException;
import com.wso2.openbanking.accelerator.common.util.CertificateUtils;
import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.security.cert.X509Certificate;
@@ -30,6 +31,13 @@
*/
public class CertificateUtilsTest {
+ private X509Certificate expiredX509Cert;
+
+ @BeforeClass
+ public void init() throws OpenBankingException {
+ this.expiredX509Cert = CommonTestUtil.getExpiredSelfCertificate();
+ }
+
@Test(description = "when valid transport cert, return x509 certificate")
public void testParseCertificate() throws OpenBankingException {
Assert.assertNotNull(CertificateUtils
@@ -69,4 +77,10 @@ public void testIsExpired() throws OpenBankingException {
Assert.assertNotNull(testCert);
Assert.assertFalse(CommonTestUtil.hasExpired(testCert));
}
+
+ @Test
+ public void testIsCertValidWithExpiredCert() {
+ Assert.assertTrue(CertificateUtils.isExpired(expiredX509Cert));
+ }
+
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/CommonTestUtil.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/CommonTestUtil.java
index c793012b..0d35ddec 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/CommonTestUtil.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/CommonTestUtil.java
@@ -18,6 +18,9 @@
package com.wso2.openbanking.accelerator.common.test.util;
+import com.wso2.openbanking.accelerator.common.exception.OpenBankingException;
+import com.wso2.openbanking.accelerator.common.util.CertificateUtils;
+
import java.io.ByteArrayInputStream;
import java.lang.reflect.Field;
import java.security.cert.CertificateException;
@@ -35,6 +38,7 @@ public class CommonTestUtil {
public static final String BEGIN_CERT = "-----BEGIN CERTIFICATE-----";
public static final String END_CERT = "-----END CERTIFICATE-----";
public static final String X509_CERT_INSTANCE_NAME = "X.509";
+ private static X509Certificate expiredSelfCertificate = null;
public static final String EIDAS_CERT = "-----BEGIN CERTIFICATE-----" +
"MIIEjDCCA3SgAwIBAgILAKTSmx6PZuerUKkwDQYJKoZIhvcNAQELBQAwSDELMAkG" +
"A1UEBhMCREUxDDAKBgNVBAoMA0JEUjERMA8GA1UECwwISVQgLSBEZXYxGDAWBgNV" +
@@ -169,6 +173,14 @@ private static Field getAccessibleField(Class> clazz, String fieldName)
return field;
}
+ public static synchronized X509Certificate getExpiredSelfCertificate()
+ throws OpenBankingException {
+ if (expiredSelfCertificate == null) {
+ expiredSelfCertificate = CertificateUtils.parseCertificate(EXPIRED_SELF_CERT);
+ }
+ return expiredSelfCertificate;
+ }
+
private static void injectIntoUnmodifiableMap(String key, String value, Object map)
throws ReflectiveOperationException {
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/impl/mtls/cert/validation/executor/CertRevocationValidationExecutor.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/impl/mtls/cert/validation/executor/CertRevocationValidationExecutor.java
index a38ff066..f6ba7956 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/impl/mtls/cert/validation/executor/CertRevocationValidationExecutor.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/impl/mtls/cert/validation/executor/CertRevocationValidationExecutor.java
@@ -20,6 +20,7 @@
import com.wso2.openbanking.accelerator.common.error.OpenBankingErrorCodes;
import com.wso2.openbanking.accelerator.common.exception.CertificateValidationException;
+import com.wso2.openbanking.accelerator.common.util.CertificateUtils;
import com.wso2.openbanking.accelerator.common.util.Generated;
import com.wso2.openbanking.accelerator.gateway.cache.CertificateRevocationCache;
import com.wso2.openbanking.accelerator.gateway.cache.GatewayCacheKey;
@@ -78,7 +79,7 @@ public void preProcessRequest(OBAPIRequestContext obapiRequestContext) {
CertificateValidationUtils.handleExecutorErrors(error, obapiRequestContext);
} else {
X509Certificate transportCertificate = transportCert.get();
- if (CertificateValidationUtils.isExpired(transportCertificate)) {
+ if (CertificateUtils.isExpired(transportCertificate)) {
LOG.error("Certificate with the serial number " +
transportCertificate.getSerialNumber() + " issued by the CA " +
transportCertificate.getIssuerDN().toString() + " is expired");
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/util/CertificateValidationUtils.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/util/CertificateValidationUtils.java
index a2fb71ad..c2d34e42 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/util/CertificateValidationUtils.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/util/CertificateValidationUtils.java
@@ -71,18 +71,6 @@ private CertificateValidationUtils() {
// Adding a private constructor to hide the implicit public one.
}
- public static boolean isExpired(X509Certificate peerCertificate) {
- try {
- peerCertificate.checkValidity();
- } catch (CertificateException e) {
- LOG.error("Certificate with the serial number " +
- peerCertificate.getSerialNumber() + " issued by the CA " +
- peerCertificate.getIssuerDN().toString() + " is expired. Caused by, " + e.getMessage());
- return true;
- }
- return false;
- }
-
/**
* Get issuer certificate from the truststore.
*
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/java/com/wso2/openbanking/accelerator/gateway/executor/impl/mtls/cert/validation/executor/CertRevocationValidationExecutorTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/java/com/wso2/openbanking/accelerator/gateway/executor/impl/mtls/cert/validation/executor/CertRevocationValidationExecutorTest.java
index 972fbe21..c9f7b963 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/java/com/wso2/openbanking/accelerator/gateway/executor/impl/mtls/cert/validation/executor/CertRevocationValidationExecutorTest.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/test/java/com/wso2/openbanking/accelerator/gateway/executor/impl/mtls/cert/validation/executor/CertRevocationValidationExecutorTest.java
@@ -20,6 +20,7 @@
import com.wso2.openbanking.accelerator.common.exception.CertificateValidationException;
import com.wso2.openbanking.accelerator.common.exception.OpenBankingException;
+import com.wso2.openbanking.accelerator.common.util.CertificateUtils;
import com.wso2.openbanking.accelerator.gateway.cache.CertificateRevocationCache;
import com.wso2.openbanking.accelerator.gateway.cache.GatewayCacheKey;
import com.wso2.openbanking.accelerator.gateway.executor.service.CertValidationService;
@@ -81,7 +82,7 @@ public IObjectFactory getObjectFactory() {
@Test(description = "When expired certificate is provided, then should return true")
public void testIsCertValidWithExpiredCert() {
- Assert.assertTrue(CertificateValidationUtils.isExpired(expiredPeerCertificate));
+ Assert.assertTrue(CertificateUtils.isExpired(expiredPeerCertificate));
}
@Test(description = "When certificate validation success, then should return false")
From 210d88f8279d03f7170cb8546745ac243427774f Mon Sep 17 00:00:00 2001
From: Rivindu
Date: Mon, 4 Mar 2024 14:07:29 +0530
Subject: [PATCH 069/281] Add MTLS certificate validator
---
.../validators/MTLSCertificateValidator.java | 62 +++++++++++
...BDefaultOIDCClaimsCallbackHandlerTest.java | 2 +-
.../identity/token/util/TestConstants.java | 33 +++++-
.../MTLSCertificateValidatorTest.java | 100 ++++++++++++++++++
.../src/test/resources/testng.xml | 5 +
5 files changed, 200 insertions(+), 2 deletions(-)
create mode 100644 open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/token/validators/MTLSCertificateValidator.java
create mode 100644 open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/token/validators/MTLSCertificateValidatorTest.java
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/token/validators/MTLSCertificateValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/token/validators/MTLSCertificateValidator.java
new file mode 100644
index 00000000..4d5d9f4d
--- /dev/null
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/token/validators/MTLSCertificateValidator.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
+ *
+ * This software is the property of WSO2 LLC. and its suppliers, if any.
+ * Dissemination of any information or reproduction of any material contained
+ * herein in any form is strictly forbidden, unless permitted by WSO2 expressly.
+ * You may not alter or remove any copyright or other notice from copies of this content.
+ */
+
+package com.wso2.openbanking.accelerator.identity.token.validators;
+
+import com.wso2.openbanking.accelerator.common.exception.OpenBankingException;
+import com.wso2.openbanking.accelerator.common.util.CertificateUtils;
+import com.wso2.openbanking.accelerator.identity.token.util.TokenFilterException;
+import com.wso2.openbanking.accelerator.identity.util.IdentityCommonConstants;
+import com.wso2.openbanking.accelerator.identity.util.IdentityCommonUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.security.cert.X509Certificate;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * MTLS Certificate Validator.
+ * Validates the expiry status of the certificate.
+ */
+public class MTLSCertificateValidator implements OBIdentityFilterValidator {
+
+ private static final Log log = LogFactory.getLog(MTLSCertificateValidator.class);
+
+ @Override
+ public void validate(ServletRequest request, String clientId) throws TokenFilterException, ServletException {
+
+ HttpServletRequest servletRequest = (HttpServletRequest) request;
+ String mtlsCertificate = servletRequest.getHeader(IdentityCommonUtil.getMTLSAuthHeader());
+ // MTLSEnforcementValidator validates the presence of the certificate.
+ if (mtlsCertificate != null) {
+ try {
+ X509Certificate x509Certificate = CertificateUtils.parseCertificate(mtlsCertificate);
+
+ if (CertificateUtils.isExpired(x509Certificate)) {
+ log.error("Certificate with the serial number " +
+ x509Certificate.getSerialNumber() + " issued by the CA " +
+ x509Certificate.getIssuerDN().toString() + " is expired");
+ throw new TokenFilterException(HttpServletResponse.SC_UNAUTHORIZED,
+ "Invalid mutual TLS request. Client certificate is expired",
+ "Certificate with the serial number " + x509Certificate.getSerialNumber() +
+ " issued by the CA " + x509Certificate.getIssuerDN().toString() + " is expired");
+ }
+ log.debug("Client certificate expiry validation completed successfully");
+ } catch (OpenBankingException e) {
+ log.error("Invalid mutual TLS request. Client certificate is invalid", e);
+ throw new TokenFilterException(HttpServletResponse.SC_UNAUTHORIZED, IdentityCommonConstants
+ .OAUTH2_INVALID_CLIENT_MESSAGE, e.getMessage());
+ }
+ }
+ }
+}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/claims/OBDefaultOIDCClaimsCallbackHandlerTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/claims/OBDefaultOIDCClaimsCallbackHandlerTest.java
index 125666d7..62cf7c5c 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/claims/OBDefaultOIDCClaimsCallbackHandlerTest.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/claims/OBDefaultOIDCClaimsCallbackHandlerTest.java
@@ -139,7 +139,7 @@ public void testHandleCustomClaims() throws OpenBankingException, IdentityOAuth2
assertEquals("123", jwtClaimsSet.getClaim("consent_id"));
- assertEquals("{x5t#S256=GA370hkNKyI1C060VmxL4xZtKyjD6aQUjrGKYWoeZX8}", jwtClaimsSet.getClaim(
+ assertEquals("{x5t#S256=k0p--ML7nfkE2pULKryszJRBx2ThBMaxHgJOePosits}", jwtClaimsSet.getClaim(
"cnf").toString());
assertEquals("aaa@gold.com", jwtClaimsSet.getClaim("sub"));
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/token/util/TestConstants.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/token/util/TestConstants.java
index ce58aef0..acc0ed66 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/token/util/TestConstants.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/token/util/TestConstants.java
@@ -24,7 +24,7 @@
public class TestConstants {
public static final String TARGET_STREAM = "targetStream";
public static final String CERTIFICATE_HEADER = "x-wso2-mutual-auth-cert";
- public static final String CERTIFICATE_CONTENT = "-----BEGIN CERTIFICATE-----" +
+ public static final String EXPIRED_CERTIFICATE_CONTENT = "-----BEGIN CERTIFICATE-----" +
"MIIFODCCBCCgAwIBAgIEWcWGxDANBgkqhkiG9w0BAQsFADBTMQswCQYDVQQGEwJH" +
"QjEUMBIGA1UEChMLT3BlbkJhbmtpbmcxLjAsBgNVBAMTJU9wZW5CYW5raW5nIFBy" +
"ZS1Qcm9kdWN0aW9uIElzc3VpbmcgQ0EwHhcNMTkwNTE2MDg0NDQ2WhcNMjAwNjE2" +
@@ -54,6 +54,37 @@ public class TestConstants {
"wtXOy27LE4exJRuZsF1CA78ObaRytuE3DJcnIRdhOcjWieS/MxZD7bzuuAPu5ySX" +
"i2/qxT3AlWtHtxrz0mKSC3rlgYAHCzCAHoASWKpf5tnB3TodPVZ6DYOu7oI=" +
"-----END CERTIFICATE-----";
+
+ public static final String CERTIFICATE_CONTENT = "-----BEGIN CERTIFICATE-----" +
+ "MIIFODCCBCCgAwIBAgIEWca5LzANBgkqhkiG9w0BAQsFADBTMQswCQYDVQQGEwJH" +
+ "QjEUMBIGA1UEChMLT3BlbkJhbmtpbmcxLjAsBgNVBAMTJU9wZW5CYW5raW5nIFBy" +
+ "ZS1Qcm9kdWN0aW9uIElzc3VpbmcgQ0EwHhcNMjMwNDE3MDQ1ODE2WhcNMjQwNTE3" +
+ "MDUyODE2WjBhMQswCQYDVQQGEwJHQjEUMBIGA1UEChMLT3BlbkJhbmtpbmcxGzAZ" +
+ "BgNVBAsTEjAwMTU4MDAwMDFIUVFyWkFBWDEfMB0GA1UEAxMWb1E0S29hYXZwT3Vv" +
+ "RTdydlFzWkVPVjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJeMaWpz" +
+ "mwYZ25cDHLSEWhcwaa/JJXgwupZJifByhaao8m/Hhx8PZpXOXz7GcfiNVmz3w1cA" +
+ "FXvfrNh4A7rc2vjp9shNQ6bQnbOKVjoN+rNxskYjxpvLOllCUaii5kjdRF5r0YE9" +
+ "7t3hH7GdATT56Js9aomykbeYodG1vN4eDcgArn1fO7q+6+0Ew2Mla5X+T/fsfu+1" +
+ "4tXMLx7AAQSCzGfsYnJp6fCJQ4uk1d5mlYWd+cM2gWf1eQ5sHeL1K9B+czos57NF" +
+ "hsVUBvPCPLmratanj78tN8O6zOxAs1UEckf+z1rLK3D2NCqv9FnfB7saLKhp58vQ" +
+ "qoRnOiW+lr1Z4bsCAwEAAaOCAgQwggIAMA4GA1UdDwEB/wQEAwIHgDAgBgNVHSUB" +
+ "Af8EFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwgeAGA1UdIASB2DCB1TCB0gYLKwYB" +
+ "BAGodYEGAWQwgcIwKgYIKwYBBQUHAgEWHmh0dHA6Ly9vYi50cnVzdGlzLmNvbS9w" +
+ "b2xpY2llczCBkwYIKwYBBQUHAgIwgYYMgYNVc2Ugb2YgdGhpcyBDZXJ0aWZpY2F0" +
+ "ZSBjb25zdGl0dXRlcyBhY2NlcHRhbmNlIG9mIHRoZSBPcGVuQmFua2luZyBSb290" +
+ "IENBIENlcnRpZmljYXRpb24gUG9saWNpZXMgYW5kIENlcnRpZmljYXRlIFByYWN0" +
+ "aWNlIFN0YXRlbWVudDBtBggrBgEFBQcBAQRhMF8wJgYIKwYBBQUHMAGGGmh0dHA6" +
+ "Ly9vYi50cnVzdGlzLmNvbS9vY3NwMDUGCCsGAQUFBzAChilodHRwOi8vb2IudHJ1" +
+ "c3Rpcy5jb20vb2JfcHBfaXNzdWluZ2NhLmNydDA6BgNVHR8EMzAxMC+gLaArhilo" +
+ "dHRwOi8vb2IudHJ1c3Rpcy5jb20vb2JfcHBfaXNzdWluZ2NhLmNybDAfBgNVHSME" +
+ "GDAWgBRQc5HGIXLTd/T+ABIGgVx5eW4/UDAdBgNVHQ4EFgQUSoZfmnXGAPddPqfH" +
+ "WVOvkxD89MgwDQYJKoZIhvcNAQELBQADggEBABHzHOJzn4DPHay8xGzlWJIxxe+X" +
+ "sNtupR5V/ouEGCzJMUPmegYeK2Kiv+Z9nJKnbspgqLil52yauKWRmiXif4FWoOPR" +
+ "wspR9ijnynCgIp6z3EAOawbe28HkaGEfAi8PMqdNAYLKpXg35TUnbP+p2Q55Grq9" +
+ "EpSR2APQfJ4TjgLgKjqLRf/RjJAY9hJbQJIUl07esYf8hH7mX6uHDCywzic+UEQ3" +
+ "tUfo7PgWmnmtyUdFcW1qAl4P80a5fb8Wq0gNu6gN5tK2bg5TfSo3Gp2It8NVu/dY" +
+ "7q3ur7CAYTXrThjg4GXUQgVqYgV3pHbr1LTAiRtac7RBhMNPCklZA78RpTM=" +
+ "-----END CERTIFICATE-----";
public static final String CLIENT_ASSERTION = "eyJraWQiOiJqeVJVY3l0MWtWQ2xjSXZsVWxjRHVrVlozdFUiLCJhbGciOiJQUzI1" +
"NiJ9.eyJzdWIiOiJpWXBSbTY0YjJ2bXZtS0RoZEw2S1pEOXo2ZmNhIiwiYXVkIjoiaHR0cHM6Ly9sb2NhbGhvc3Q6OTQ0My9vYXV0a" +
"DIvdG9rZW4iLCJpc3MiOiJpWXBSbTY0YjJ2bXZtS0RoZEw2S1pEOXo2ZmNhIiwiZXhwIjoxNjEwNjMxNDEyLCJpYXQiOjE2MTA2MDE" +
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/token/validators/MTLSCertificateValidatorTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/token/validators/MTLSCertificateValidatorTest.java
new file mode 100644
index 00000000..ea516789
--- /dev/null
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/token/validators/MTLSCertificateValidatorTest.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
+ *
+ * This software is the property of WSO2 LLC. and its suppliers, if any.
+ * Dissemination of any information or reproduction of any material contained
+ * herein in any form is strictly forbidden, unless permitted by WSO2 expressly.
+ * You may not alter or remove any copyright or other notice from copies of this content.
+ */
+
+package com.wso2.openbanking.accelerator.identity.token.validators;
+
+import com.wso2.openbanking.accelerator.common.exception.OpenBankingException;
+import com.wso2.openbanking.accelerator.identity.internal.IdentityExtensionsDataHolder;
+import com.wso2.openbanking.accelerator.identity.token.DefaultTokenFilter;
+import com.wso2.openbanking.accelerator.identity.token.TokenFilter;
+import com.wso2.openbanking.accelerator.identity.token.util.TestConstants;
+import com.wso2.openbanking.accelerator.identity.token.util.TestUtil;
+import com.wso2.openbanking.accelerator.identity.util.IdentityCommonConstants;
+import com.wso2.openbanking.accelerator.identity.util.IdentityCommonUtil;
+import org.apache.http.HttpStatus;
+import org.mockito.Mockito;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.testng.PowerMockTestCase;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+
+import static org.testng.Assert.assertEquals;
+
+@PrepareForTest({IdentityCommonUtil.class})
+@PowerMockIgnore({"jdk.internal.reflect.*"})
+public class MTLSCertificateValidatorTest extends PowerMockTestCase {
+
+ MockHttpServletResponse response;
+ MockHttpServletRequest request;
+ FilterChain filterChain;
+ TokenFilter filter;
+
+ @BeforeMethod
+ public void beforeMethod() throws ReflectiveOperationException, IOException, OpenBankingException {
+
+ request = new MockHttpServletRequest();
+ response = new MockHttpServletResponse();
+ filterChain = Mockito.spy(FilterChain.class);
+
+ List validators = new ArrayList<>();
+ MTLSCertificateValidator mtlsCertificateValidator = Mockito.spy(MTLSCertificateValidator.class);
+ validators.add(mtlsCertificateValidator);
+
+ filter = Mockito.spy(TokenFilter.class);
+ Mockito.doReturn(new DefaultTokenFilter()).when(filter).getDefaultTokenFilter();
+ Mockito.doReturn(validators).when(filter).getValidators();
+ PowerMockito.mockStatic(IdentityCommonUtil.class);
+ PowerMockito.when(IdentityCommonUtil.getMTLSAuthHeader()).thenReturn(TestConstants.CERTIFICATE_HEADER);
+ PowerMockito.when(IdentityCommonUtil.getRegulatoryFromSPMetaData("test")).thenReturn(true);
+ Map configMap = new HashMap<>();
+ configMap.put(IdentityCommonConstants.ENABLE_TRANSPORT_CERT_AS_HEADER, true);
+ configMap.put(IdentityCommonConstants.CLIENT_CERTIFICATE_ENCODE, false);
+ IdentityExtensionsDataHolder.getInstance().setConfigurationMap(configMap);
+
+ request.setParameter(IdentityCommonConstants.CLIENT_ID, "test");
+ request.setAttribute(IdentityCommonConstants.JAVAX_SERVLET_REQUEST_CERTIFICATE, null);
+
+ }
+
+ @Test(description = "Test whether the expired certificate fails")
+ public void testMTLSCertValidationWithExpiredCertificate() throws IOException, ServletException {
+
+ request.addHeader(TestConstants.CERTIFICATE_HEADER, TestConstants.EXPIRED_CERTIFICATE_CONTENT);
+
+ filter.doFilter(request, response, filterChain);
+ Map responseMap = TestUtil.getResponse(response.getOutputStream());
+ assertEquals(response.getStatus(), HttpStatus.SC_UNAUTHORIZED);
+ assertEquals(responseMap.get(IdentityCommonConstants.OAUTH_ERROR), "invalid_client");
+ assertEquals(responseMap.get(IdentityCommonConstants.OAUTH_ERROR_DESCRIPTION),
+ "Invalid mutual TLS request. Client certificate is expired");
+
+ }
+
+ @Test(description = "Test whether the expired certificate fails")
+ public void testMTLSCertValidationWithValidCertificate() throws IOException, ServletException {
+
+ request.addHeader(TestConstants.CERTIFICATE_HEADER, TestConstants.CERTIFICATE_CONTENT);
+
+ filter.doFilter(request, response, filterChain);
+ assertEquals(response.getStatus(), HttpStatus.SC_OK);
+ }
+}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/resources/testng.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/resources/testng.xml
index cd41c6f2..0f4e00ef 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/resources/testng.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/resources/testng.xml
@@ -29,6 +29,11 @@
+
+
+
+
+
From 2d243834d9b4786601869edbbff0421acf10902f Mon Sep 17 00:00:00 2001
From: Rivindu
Date: Mon, 4 Mar 2024 14:07:49 +0530
Subject: [PATCH 070/281] Config change to add MTLS certificate validator
---
.../resources/conf/templates/repository/conf/open-banking.xml.j2 | 1 +
1 file changed, 1 insertion(+)
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2 b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
index f9c86194..3f8c044b 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
@@ -93,6 +93,7 @@
{% endfor %}
{% else %}
com.wso2.openbanking.accelerator.identity.token.validators.MTLSEnforcementValidator
+ com.wso2.openbanking.accelerator.identity.token.validators.MTLSCertificateValidatorcom.wso2.openbanking.accelerator.identity.token.validators.SignatureAlgorithmEnforcementValidatorcom.wso2.openbanking.accelerator.identity.token.validators.ClientAuthenticatorValidator
{% endif %}
From 02cc94ac500f44742a4bf39aa013c9521443fcb4 Mon Sep 17 00:00:00 2001
From: Ashirwada
Date: Mon, 4 Mar 2024 14:54:00 +0530
Subject: [PATCH 071/281] Moving Idempotency Validation to consent management
component
---
.../IdempotencyValidationResult.java | 3 +
.../idempotency/IdempotencyValidator.java | 4 +-
.../IdempotencyValidatorTests.java | 242 ++++++++++++++++++
.../src/test/resources/testng.xml | 1 +
4 files changed, 247 insertions(+), 3 deletions(-)
create mode 100644 open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidatorTests.java
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidationResult.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidationResult.java
index cbf6493d..32745967 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidationResult.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidationResult.java
@@ -30,6 +30,9 @@ public class IdempotencyValidationResult {
private DetailedConsentResource consent;
private String consentId;
+ public IdempotencyValidationResult() {
+ }
+
public IdempotencyValidationResult(boolean isIdempotent, boolean isValid, DetailedConsentResource consent,
String consentId) {
this.isIdempotent = isIdempotent;
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
index 947f93d4..f6fe9ed4 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
@@ -46,11 +46,9 @@ public class IdempotencyValidator {
private static final OpenBankingConfigParser parser = OpenBankingConfigParser.getInstance();
private static final ConsentCoreService consentCoreService = ConsentExtensionsDataHolder.getInstance()
.getConsentCoreService();
- public static final String IDEMPOTENCY_IS_ENABLED = "Consent.Idempotency.IsEnabled";
+ private static final String IDEMPOTENCY_IS_ENABLED = "Consent.Idempotency.IsEnabled";
private static final String IDEMPOTENCY_ALLOWED_TIME = "Consent.Idempotency.AllowedTimeDuration";
- public IdempotencyValidator() {
- }
/**
* Method to check whether the request is idempotent.
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidatorTests.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidatorTests.java
new file mode 100644
index 00000000..a08b970a
--- /dev/null
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidatorTests.java
@@ -0,0 +1,242 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.openbanking.accelerator.consent.extensions.common.idempotency;
+
+import com.wso2.openbanking.accelerator.common.config.OpenBankingConfigParser;
+import com.wso2.openbanking.accelerator.common.exception.ConsentManagementException;
+import com.wso2.openbanking.accelerator.consent.extensions.internal.ConsentExtensionsDataHolder;
+import com.wso2.openbanking.accelerator.consent.mgt.dao.models.DetailedConsentResource;
+import com.wso2.openbanking.accelerator.consent.mgt.service.impl.ConsentCoreServiceImpl;
+import org.mockito.Mockito;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import java.time.OffsetDateTime;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * Test class for IdempotencyValidator.
+ */
+@PrepareForTest({OpenBankingConfigParser.class, ConsentExtensionsDataHolder.class})
+@PowerMockIgnore("jdk.internal.reflect.*")
+public class IdempotencyValidatorTests {
+
+ private ConsentCoreServiceImpl consentCoreServiceImpl;
+ private ArrayList consentIdList;
+ private String consentId;
+ private Map configs;
+ private static final String IDEMPOTENCY_IS_ENABLED = "Consent.Idempotency.IsEnabled";
+ private static final String IDEMPOTENCY_ALLOWED_TIME = "Consent.Idempotency.AllowedTimeDuration";
+
+ private static final String PAYLOAD = "{\n" +
+ " \"Data\": {\n" +
+ " \"ReadRefundAccount\": \"Yes\",\n" +
+ " \"Initiation\": {\n" +
+ " \"InstructionIdentification\": \"ACME412\",\n" +
+ " \"EndToEndIdentification\": \"FRESCO.21302.GFX.20\",\n" +
+ " \"InstructedAmount\": {\n" +
+ " \"Amount\": \"165.88\",\n" +
+ " \"Currency\": \"GBP\"\n" +
+ " },\n" +
+ " \"CreditorAccount\": {\n" +
+ " \"SchemeName\": \"UK.OBIE.SortCodeAccountNumber\",\n" +
+ " \"Identification\": \"08080021325698\",\n" +
+ " \"Name\": \"ACME Inc\",\n" +
+ " \"SecondaryIdentification\": \"0002\"\n" +
+ " },\n" +
+ " \"RemittanceInformation\": {\n" +
+ " \"Reference\": \"FRESCO-101\",\n" +
+ " \"Unstructured\": \"Internal ops code 5120101\"\n" +
+ " }\n" +
+ " }\n" +
+ " },\n" +
+ " \"Risk\": {\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+
+ private static final String DIFFERENT_PAYLOAD = "{\n" +
+ " \"Data\": {\n" +
+ " \"ReadRefundAccount\": \"No\",\n" +
+ " \"Initiation\": {\n" +
+ " \"InstructionIdentification\": \"ACME413\",\n" +
+ " \"EndToEndIdentification\": \"FRESCO.21302.GFX.20\",\n" +
+ " \"InstructedAmount\": {\n" +
+ " \"Amount\": \"165.88\",\n" +
+ " \"Currency\": \"GBP\"\n" +
+ " },\n" +
+ " \"CreditorAccount\": {\n" +
+ " \"SchemeName\": \"UK.OBIE.SortCodeAccountNumber\",\n" +
+ " \"Identification\": \"08080021325698\",\n" +
+ " \"Name\": \"ACME Inc\",\n" +
+ " \"SecondaryIdentification\": \"0002\"\n" +
+ " },\n" +
+ " \"RemittanceInformation\": {\n" +
+ " \"Reference\": \"FRESCO-101\",\n" +
+ " \"Unstructured\": \"Internal ops code 5120101\"\n" +
+ " }\n" +
+ " }\n" +
+ " },\n" +
+ " \"Risk\": {\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+
+
+ @BeforeClass
+ public void beforeTest() {
+ configs = new HashMap<>();
+ configs.put(IDEMPOTENCY_IS_ENABLED, "true");
+ configs.put(IDEMPOTENCY_ALLOWED_TIME, "1");
+
+ consentCoreServiceImpl = Mockito.mock(ConsentCoreServiceImpl.class);
+ OpenBankingConfigParser openBankingConfigParserMock = Mockito.mock(OpenBankingConfigParser.class);
+ Mockito.doReturn(configs).when(openBankingConfigParserMock).getConfiguration();
+ ConsentExtensionsDataHolder consentExtensionsDataHolderMock = Mockito.mock(ConsentExtensionsDataHolder.class);
+
+ PowerMockito.mockStatic(OpenBankingConfigParser.class);
+ PowerMockito.when(OpenBankingConfigParser.getInstance()).thenReturn(openBankingConfigParserMock);
+
+ PowerMockito.mockStatic(ConsentExtensionsDataHolder.class);
+ PowerMockito.when(ConsentExtensionsDataHolder.getInstance()).thenReturn(consentExtensionsDataHolderMock);
+ PowerMockito.when(consentExtensionsDataHolderMock.getConsentCoreService()).thenReturn(consentCoreServiceImpl);
+
+ consentId = UUID.randomUUID().toString();
+ consentIdList = new ArrayList<>();
+ consentIdList.add(consentId);
+ }
+
+ @Test
+ public void testValidateIdempotency() throws ConsentManagementException {
+ OffsetDateTime offsetDateTime = OffsetDateTime.now();
+
+ Mockito.doReturn(consentIdList).when(consentCoreServiceImpl)
+ .getConsentIdByConsentAttributeNameAndValue(Mockito.anyString(), Mockito.anyString());
+ Mockito.doReturn(getConsent(offsetDateTime.toEpochSecond())).when(consentCoreServiceImpl)
+ .getDetailedConsent(Mockito.anyString());
+ IdempotencyValidationResult result = IdempotencyValidator.validateIdempotency("IdempotencyKey",
+ "123456", PAYLOAD);
+
+ Assert.assertTrue(result.isIdempotent());
+ Assert.assertTrue(result.isValid());
+ Assert.assertNotNull(result.getConsent());
+ Assert.assertEquals(consentId, result.getConsentId());
+ }
+
+ @Test
+ public void testValidateIdempotencyWithoutIdempotencyKeyName() {
+ IdempotencyValidationResult result = IdempotencyValidator.validateIdempotency(null, "", "");
+
+ Assert.assertFalse(result.isIdempotent());
+ }
+
+ @Test
+ public void testValidateIdempotencyWithoutIdempotencyKeyValue() {
+ IdempotencyValidationResult result = IdempotencyValidator.validateIdempotency("IdempotencyKey", null, "");
+
+ Assert.assertFalse(result.isIdempotent());
+ }
+
+ @Test
+ public void testValidateIdempotencyWithoutRequest() {
+ IdempotencyValidationResult result = IdempotencyValidator.validateIdempotency("IdempotencyKey", "123456", "");
+
+ Assert.assertFalse(result.isIdempotent());
+ }
+
+ @Test
+ public void testValidateIdempotencyRetrievingAttributesWithException() throws ConsentManagementException {
+
+ Mockito.doThrow(ConsentManagementException.class).when(consentCoreServiceImpl)
+ .getConsentIdByConsentAttributeNameAndValue(Mockito.anyString(), Mockito.anyString());
+ IdempotencyValidationResult result = IdempotencyValidator.validateIdempotency("IdempotencyKey",
+ "123456", "test");
+
+ Assert.assertFalse(result.isIdempotent());
+ }
+
+ @Test
+ public void testValidateIdempotencyWithoutAttribute() throws ConsentManagementException {
+
+ Mockito.doReturn(new ArrayList<>()).when(consentCoreServiceImpl)
+ .getConsentIdByConsentAttributeNameAndValue(Mockito.anyString(), Mockito.anyString());
+ IdempotencyValidationResult result = IdempotencyValidator.validateIdempotency("IdempotencyKey",
+ "123456", "test");
+
+ Assert.assertFalse(result.isIdempotent());
+ }
+
+ @Test
+ public void testValidateIdempotencyWithNullConsentRequest() throws ConsentManagementException {
+
+ Mockito.doReturn(consentIdList).when(consentCoreServiceImpl)
+ .getConsentIdByConsentAttributeNameAndValue(Mockito.anyString(), Mockito.anyString());
+ Mockito.doReturn(null).when(consentCoreServiceImpl).getDetailedConsent(Mockito.anyString());
+ IdempotencyValidationResult result = IdempotencyValidator.validateIdempotency("IdempotencyKey",
+ "123456", "test");
+
+ Assert.assertTrue(result.isIdempotent());
+ Assert.assertFalse(result.isValid());
+ }
+
+ @Test
+ public void testValidateIdempotencyWithNonMatchingPayload() throws ConsentManagementException {
+
+ Mockito.doReturn(consentIdList).when(consentCoreServiceImpl)
+ .getConsentIdByConsentAttributeNameAndValue(Mockito.anyString(), Mockito.anyString());
+ Mockito.doReturn(getConsent(System.currentTimeMillis())).when(consentCoreServiceImpl)
+ .getDetailedConsent(Mockito.anyString());
+ IdempotencyValidationResult result = IdempotencyValidator.validateIdempotency("IdempotencyKey",
+ "123456", DIFFERENT_PAYLOAD);
+
+ Assert.assertTrue(result.isIdempotent());
+ Assert.assertFalse(result.isValid());
+ }
+
+ @Test
+ public void testValidateIdempotencyAfterAllowedTime() throws ConsentManagementException {
+
+ OffsetDateTime offsetDateTime = OffsetDateTime.now().minusHours(2);
+
+ Mockito.doReturn(consentIdList).when(consentCoreServiceImpl)
+ .getConsentIdByConsentAttributeNameAndValue(Mockito.anyString(), Mockito.anyString());
+ Mockito.doReturn(getConsent(offsetDateTime.toEpochSecond())).when(consentCoreServiceImpl)
+ .getDetailedConsent(Mockito.anyString());
+ IdempotencyValidationResult result = IdempotencyValidator.validateIdempotency("IdempotencyKey",
+ "123456", DIFFERENT_PAYLOAD);
+
+ Assert.assertTrue(result.isIdempotent());
+ Assert.assertFalse(result.isValid());
+ }
+
+ private DetailedConsentResource getConsent(long createdTime) {
+ DetailedConsentResource consent = new DetailedConsentResource();
+ consent.setConsentID(consentId);
+ consent.setReceipt(PAYLOAD);
+ consent.setCreatedTime(createdTime);
+ return consent;
+ }
+}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/resources/testng.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/resources/testng.xml
index a3747971..06319e64 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/resources/testng.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/resources/testng.xml
@@ -26,6 +26,7 @@
+
From fad705b34ce6e4e2994210714a7f1a00085939f2 Mon Sep 17 00:00:00 2001
From: Ashirwada
Date: Mon, 4 Mar 2024 15:13:39 +0530
Subject: [PATCH 072/281] Fixed review comments
---
.../conf/templates/repository/conf/open-banking.xml.j2 | 8 ++++----
.../common/idempotency/IdempotencyValidator.java | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2 b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
index c26a57bc..5726160a 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
@@ -396,14 +396,14 @@
- {% if open_banking.gateway.idempotency.enabled is defined %}
- {{open_banking.gateway.idempotency.enabled}}
+ {% if open_banking.consent.idempotency.enabled is defined %}
+ {{open_banking.consent.idempotency.enabled}}
{% else %}
false
{% endif %}
- {% if open_banking.gateway.idempotency.allowed_time_duration is defined %}
- {{open_banking.gateway.idempotency.allowed_time_duration}}
+ {% if open_banking.consent.idempotency.allowed_time_duration is defined %}
+ {{open_banking.consent.idempotency.allowed_time_duration}}
{% else %}
1440
{% endif %}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
index f6fe9ed4..ffcf0873 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
@@ -46,7 +46,7 @@ public class IdempotencyValidator {
private static final OpenBankingConfigParser parser = OpenBankingConfigParser.getInstance();
private static final ConsentCoreService consentCoreService = ConsentExtensionsDataHolder.getInstance()
.getConsentCoreService();
- private static final String IDEMPOTENCY_IS_ENABLED = "Consent.Idempotency.IsEnabled";
+ private static final String IDEMPOTENCY_IS_ENABLED = "Consent.Idempotency.Enabled";
private static final String IDEMPOTENCY_ALLOWED_TIME = "Consent.Idempotency.AllowedTimeDuration";
From b796dbcc55922954d93e9a8e190e053f474277ca Mon Sep 17 00:00:00 2001
From: Ashirwada
Date: Mon, 4 Mar 2024 16:35:55 +0530
Subject: [PATCH 073/281] Fixed review comments
---
open-banking-accelerator/accelerators/ob-apim/pom.xml | 3 ---
open-banking-accelerator/accelerators/ob-is/pom.xml | 1 -
2 files changed, 4 deletions(-)
diff --git a/open-banking-accelerator/accelerators/ob-apim/pom.xml b/open-banking-accelerator/accelerators/ob-apim/pom.xml
index 889a447b..5dff7c99 100644
--- a/open-banking-accelerator/accelerators/ob-apim/pom.xml
+++ b/open-banking-accelerator/accelerators/ob-apim/pom.xml
@@ -53,9 +53,6 @@
${project.basedir}/carbon-home/repository/components/dropins
-
- **/hazelcast-5.0.2.jar
- ${project.basedir}/carbon-home/repository/deployment/server/webapps
diff --git a/open-banking-accelerator/accelerators/ob-is/pom.xml b/open-banking-accelerator/accelerators/ob-is/pom.xml
index 23f57b98..cea112b7 100644
--- a/open-banking-accelerator/accelerators/ob-is/pom.xml
+++ b/open-banking-accelerator/accelerators/ob-is/pom.xml
@@ -59,7 +59,6 @@
**/org.wso2.carbon.identity.application.authenticator.push-0.1.1.jar**/org.wso2.carbon.identity.application.authenticator.push.common-0.1.1.jar**/org.wso2.carbon.identity.application.authenticator.push.device.handler-0.1.1.jar
- **/hazelcast-5.0.2.jar
From 37362bdaabbb8d2d73462cc85f4e943ed4625a63 Mon Sep 17 00:00:00 2001
From: Rivindu
Date: Mon, 4 Mar 2024 17:19:12 +0530
Subject: [PATCH 074/281] Fix review comment
---
.../token/validators/MTLSCertificateValidator.java | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/token/validators/MTLSCertificateValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/token/validators/MTLSCertificateValidator.java
index 4d5d9f4d..d1f45971 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/token/validators/MTLSCertificateValidator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/token/validators/MTLSCertificateValidator.java
@@ -31,6 +31,8 @@
public class MTLSCertificateValidator implements OBIdentityFilterValidator {
private static final Log log = LogFactory.getLog(MTLSCertificateValidator.class);
+ private static final String CERT_EXPIRED_ERROR = "Certificate with the serial number %s issued by the CA %s is " +
+ "expired";
@Override
public void validate(ServletRequest request, String clientId) throws TokenFilterException, ServletException {
@@ -43,13 +45,12 @@ public void validate(ServletRequest request, String clientId) throws TokenFilter
X509Certificate x509Certificate = CertificateUtils.parseCertificate(mtlsCertificate);
if (CertificateUtils.isExpired(x509Certificate)) {
- log.error("Certificate with the serial number " +
- x509Certificate.getSerialNumber() + " issued by the CA " +
- x509Certificate.getIssuerDN().toString() + " is expired");
+ log.error(String.format(CERT_EXPIRED_ERROR, x509Certificate.getSerialNumber(),
+ x509Certificate.getIssuerDN().toString()));
throw new TokenFilterException(HttpServletResponse.SC_UNAUTHORIZED,
"Invalid mutual TLS request. Client certificate is expired",
- "Certificate with the serial number " + x509Certificate.getSerialNumber() +
- " issued by the CA " + x509Certificate.getIssuerDN().toString() + " is expired");
+ String.format(CERT_EXPIRED_ERROR, x509Certificate.getSerialNumber(),
+ x509Certificate.getIssuerDN().toString()));
}
log.debug("Client certificate expiry validation completed successfully");
} catch (OpenBankingException e) {
From 243855ead9e5a84fb6d9e3ec75c11a8c8bd3d4a8 Mon Sep 17 00:00:00 2001
From: Ashirwada
Date: Mon, 4 Mar 2024 17:28:55 +0530
Subject: [PATCH 075/281] Fixed review comments
---
.../common/test/util/SecurityUtilsTest.java | 28 +++++++++----------
.../IdempotencyValidatorTests.java | 2 +-
2 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/SecurityUtilsTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/SecurityUtilsTest.java
index a587f722..2e9437f0 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/SecurityUtilsTest.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/SecurityUtilsTest.java
@@ -22,6 +22,8 @@
import org.testng.Assert;
import org.testng.annotations.Test;
+import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -38,24 +40,22 @@ public void testSanitizeString() {
@Test
public void testSanitizeStringList() {
- List sanitizedList = SecurityUtils.sanitize(List.of(
- "tests\nsanitizing",
- "tests\nsanitizing",
- "tests\nsanitizing"
- )
- );
- Assert.assertFalse(sanitizedList.stream().anyMatch(s -> s.contains("\n")));
+ List sanitizedList = new ArrayList<>();
+ sanitizedList.add("tests\nsanitizing");
+ sanitizedList.add("tests\nsan\nitizing");
+ sanitizedList.add("tests\nsanitizing\n");
+
+ Assert.assertFalse(SecurityUtils.sanitize(sanitizedList).stream().anyMatch(s -> s.contains("\n")));
}
@Test
public void testSanitizeStringSet() {
- Set sanitizedList = SecurityUtils.sanitize(Set.of(
- "tests\nsanitizing",
- "tests\nsanitizingtext",
- "tests\nsanitizingwords"
- )
- );
- Assert.assertFalse(sanitizedList.stream().anyMatch(s -> s.contains("\n")));
+ Set sanitizedList = new HashSet<>();
+ sanitizedList.add("tests\nsanitizing");
+ sanitizedList.add("tests\nsanitizingtext");
+ sanitizedList.add("tests\nsanitizingwords");
+
+ Assert.assertFalse(SecurityUtils.sanitize(sanitizedList).stream().anyMatch(s -> s.contains("\n")));
}
@Test
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidatorTests.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidatorTests.java
index a08b970a..7e0c00a1 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidatorTests.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidatorTests.java
@@ -48,7 +48,7 @@ public class IdempotencyValidatorTests {
private ArrayList consentIdList;
private String consentId;
private Map configs;
- private static final String IDEMPOTENCY_IS_ENABLED = "Consent.Idempotency.IsEnabled";
+ private static final String IDEMPOTENCY_IS_ENABLED = "Consent.Idempotency.Enabled";
private static final String IDEMPOTENCY_ALLOWED_TIME = "Consent.Idempotency.AllowedTimeDuration";
private static final String PAYLOAD = "{\n" +
From e431fc54b187563b7f9749ca158256ff1477f40e Mon Sep 17 00:00:00 2001
From: Ashirwada
Date: Tue, 5 Mar 2024 08:29:20 +0530
Subject: [PATCH 076/281] Fixed build issue
---
.../common/idempotency/IdempotencyValidator.java | 16 +---------------
1 file changed, 1 insertion(+), 15 deletions(-)
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
index ffcf0873..f8eeecf2 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
@@ -35,6 +35,7 @@
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.Date;
+import java.util.HashMap;
import java.util.Map;
/**
@@ -106,21 +107,6 @@ public static IdempotencyValidationResult validateIdempotency(String idempotency
return new IdempotencyValidationResult(false, false, null, null);
}
- /**
- * Method to store the idempotency key in the database.
- *
- * @param consentId Consent ID
- * @param idempotencyKeyName Idempotency Key Name
- * @param idempotencyKeyValue Idempotency Key Value
- * @return Whether the idempotency key is stored in the database
- * @throws ConsentManagementException If an error occurs while storing the idempotency key
- */
- public static boolean storeIdempotencyKeyInAttributes(String consentId, String idempotencyKeyName,
- String idempotencyKeyValue) throws ConsentManagementException {
-
- return consentCoreService.storeConsentAttributes(consentId, Map.of(idempotencyKeyName, idempotencyKeyValue));
- }
-
/**
* Method to retrieve the consent ids that have the idempotency key name and value as attribute.
*
From b3449489d9d61470a1f72157ba87c22baa79d0e5 Mon Sep 17 00:00:00 2001
From: Ashirwada
Date: Tue, 5 Mar 2024 09:19:24 +0530
Subject: [PATCH 077/281] Fixed build issue
---
.../extensions/common/idempotency/IdempotencyValidator.java | 2 --
1 file changed, 2 deletions(-)
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
index f8eeecf2..363cd323 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
@@ -35,8 +35,6 @@
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
/**
* Class to handle idempotency related operations.
From 28d7b78a3be612fece409c5e7e5dc13cf49b0af4 Mon Sep 17 00:00:00 2001
From: Ashirwada
Date: Tue, 5 Mar 2024 11:59:59 +0530
Subject: [PATCH 078/281] Fixed review comments
---
.../common/idempotency/IdempotencyValidatorTests.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidatorTests.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidatorTests.java
index 7e0c00a1..8ed8ee7d 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidatorTests.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidatorTests.java
@@ -113,9 +113,10 @@ public void beforeTest() {
configs.put(IDEMPOTENCY_ALLOWED_TIME, "1");
consentCoreServiceImpl = Mockito.mock(ConsentCoreServiceImpl.class);
- OpenBankingConfigParser openBankingConfigParserMock = Mockito.mock(OpenBankingConfigParser.class);
+ OpenBankingConfigParser openBankingConfigParserMock = PowerMockito.mock(OpenBankingConfigParser.class);
Mockito.doReturn(configs).when(openBankingConfigParserMock).getConfiguration();
- ConsentExtensionsDataHolder consentExtensionsDataHolderMock = Mockito.mock(ConsentExtensionsDataHolder.class);
+ ConsentExtensionsDataHolder consentExtensionsDataHolderMock = PowerMockito
+ .mock(ConsentExtensionsDataHolder.class);
PowerMockito.mockStatic(OpenBankingConfigParser.class);
PowerMockito.when(OpenBankingConfigParser.getInstance()).thenReturn(openBankingConfigParserMock);
From b4a872e97b1f5665d81e42c003fb6a9669c73376 Mon Sep 17 00:00:00 2001
From: Ashirwada
Date: Tue, 5 Mar 2024 14:05:50 +0530
Subject: [PATCH 079/281] Fixed review comments
---
.../repository/conf/open-banking.xml.j2 | 77 -------------------
1 file changed, 77 deletions(-)
diff --git a/open-banking-accelerator/accelerators/ob-apim/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2 b/open-banking-accelerator/accelerators/ob-apim/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
index d821a49e..8a9d761a 100644
--- a/open-banking-accelerator/accelerators/ob-apim/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
+++ b/open-banking-accelerator/accelerators/ob-apim/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
@@ -477,83 +477,6 @@
{% endif %}
-
- {% if open_banking.distributed_cache.enabled is defined %}
- {{open_banking.distributed_cache.enabled}}
- {% else %}
- false
- {% endif %}
- {% if open_banking.distributed_cache.host_name is defined %}
- {{open_banking.distributed_cache.host_name}}
- {% else %}
- localhost
- {% endif %}
- {% if open_banking.distributed_cache.port is defined %}
- {{open_banking.distributed_cache.port}}
- {% else %}
- 5701
- {% endif %}
- {% if ( (open_banking.distributed_cache.discovery_mechanism is defined) and (open_banking.distributed_cache.discovery_mechanism == "TCP") ) %}
- {{open_banking.distributed_cache.discovery_mechanism}}
- {% if open_banking.distributed_cache.members is defined %}
-
- {% for member in open_banking.distributed_cache.members %}
- {{member}}
- {% endfor %}
-
- {% else %}
-
- {% endif %}
- {% else %}
- Multicast
- {% if open_banking.distributed_cache.multicast_group is defined %}
- {{open_banking.distributed_cache.multicast_group}}
- {% else %}
- 224.2.2.3
- {% endif %}
- {% if open_banking.distributed_cache.multicast_port is defined %}
- {{open_banking.distributed_cache.multicast_port}}
- {% else %}
- 54321
- {% endif %}
- {% if open_banking.distributed_cache.trusted_interfaces is defined %}
-
- {% for trusted_interface in open_banking.distributed_cache.trusted_interfaces %}
- {{trusted_interface}}
- {% endfor %}
-
- {% else %}
-
- {% endif %}
- {% endif %}
-
- {% if open_banking.distributed_cache.properties.max_heartbeat is defined %}
- {{open_banking.distributed_cache.properties.max_heartbeat}}
- {% else %}
- 600
- {% endif %}
- {% if open_banking.distributed_cache.properties.max_master_confirmation is defined %}
- {{open_banking.distributed_cache.properties.max_master_confirmation}}
- {% else %}
- 900
- {% endif %}
- {% if open_banking.distributed_cache.properties.merge_first_run_delay is defined %}
- {{open_banking.distributed_cache.properties.merge_first_run_delay}}
- {% else %}
- 60
- {% endif %}
- {% if open_banking.distributed_cache.properties.merge_next_run_delay is defined %}
- {{open_banking.distributed_cache.properties.merge_next_run_delay}}
- {% else %}
- 30
- {% endif %}
- {% if open_banking.distributed_cache.properties.logging_type is defined %}
- {{open_banking.distributed_cache.properties.logging_type}}
- {% else %}
- none
- {% endif %}
-
-
From a20ff5a439a4241c61ca71287e8906d34a4e36af Mon Sep 17 00:00:00 2001
From: Ashirwada
Date: Tue, 5 Mar 2024 17:28:44 +0530
Subject: [PATCH 080/281] Fixed review comments
---
.../idempotency/IdempotencyValidator.java | 60 ++++++++++++-------
.../IdempotencyValidatorTests.java | 36 ++++++++---
2 files changed, 67 insertions(+), 29 deletions(-)
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
index 363cd323..cea3e252 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
@@ -35,6 +35,7 @@
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.Date;
+import java.util.Map;
/**
* Class to handle idempotency related operations.
@@ -42,7 +43,7 @@
public class IdempotencyValidator {
private static final Log log = LogFactory.getLog(IdempotencyValidator.class);
- private static final OpenBankingConfigParser parser = OpenBankingConfigParser.getInstance();
+ private static final Map configs = OpenBankingConfigParser.getInstance().getConfiguration();
private static final ConsentCoreService consentCoreService = ConsentExtensionsDataHolder.getInstance()
.getConsentCoreService();
private static final String IDEMPOTENCY_IS_ENABLED = "Consent.Idempotency.Enabled";
@@ -60,8 +61,8 @@ public class IdempotencyValidator {
* @return IdempotencyValidationResult
*/
public static IdempotencyValidationResult validateIdempotency(String idempotencyKeyName, String idempotencyKeyValue,
- String request) {
- if (Boolean.parseBoolean((String) parser.getConfiguration().get(IDEMPOTENCY_IS_ENABLED))) {
+ String request, String clientId) {
+ if (Boolean.parseBoolean((String) configs.get(IDEMPOTENCY_IS_ENABLED))) {
if (idempotencyKeyValue == null || request.isEmpty()) {
log.debug("Idempotency Key Value or Request is empty. Hence cannot proceed with " +
"idempotency validation");
@@ -70,25 +71,32 @@ public static IdempotencyValidationResult validateIdempotency(String idempotency
try {
ArrayList consentIds = getConsentIdsFromIdempotencyKey(idempotencyKeyName,
idempotencyKeyValue);
- if (isIdempotencyKeyExists(consentIds)) {
- log.debug("Idempotency Key exists in the database. Hence this is an idempotent request");
+ if (isListNotEmpty(consentIds)) {
+ log.debug(String.format("Idempotency Key %s exists in the database. Hence this is an idempotent" +
+ " request", idempotencyKeyValue));
for (String consentId : consentIds) {
DetailedConsentResource consentRequest = consentCoreService.getDetailedConsent(consentId);
if (consentRequest != null) {
- if (isJSONPayloadSimilar(consentRequest.getReceipt(), request)) {
- if (isRequestReceivedWithinAllowedTime(consentRequest.getCreatedTime())) {
- log.debug("Payloads are similar and request received within allowed time." +
- " Hence this is a valid idempotent request");
- return new IdempotencyValidationResult(true, true,
- consentRequest, consentId);
+ if (isClientIdsMatching(clientId, consentRequest.getClientID())) {
+ if (isJSONPayloadSimilar(consentRequest.getReceipt(), request)) {
+ if (isRequestReceivedWithinAllowedTime(consentRequest.getCreatedTime())) {
+ log.debug("Payloads are similar and request received within allowed time." +
+ " Hence this is a valid idempotent request");
+ return new IdempotencyValidationResult(true, true,
+ consentRequest, consentId);
+ } else {
+ log.debug("Payloads are similar and request is not within allowed time." +
+ " Hence this is not a valid idempotent request");
+ return new IdempotencyValidationResult(true, false, null, null);
+ }
} else {
- log.debug("Payloads are similar and request is not within allowed time." +
- " Hence this is not a valid idempotent request");
+ log.debug("Payloads are not similar, Hence this is not a valid idempotent " +
+ "request");
return new IdempotencyValidationResult(true, false, null, null);
}
} else {
- log.debug("Payloads are not similar, Hence this is not a valid idempotent " +
- "request");
+ log.debug("Client ID sent in the request does not match with the client ID in the" +
+ " retrieved consent. Hence this is not a valid idempotent request");
return new IdempotencyValidationResult(true, false, null, null);
}
} else {
@@ -124,15 +132,28 @@ private static ArrayList getConsentIdsFromIdempotencyKey(String idempote
}
/**
- * Method to check whether the idempotency key exists in the database.
+ * Method to check whether the consent ID list is not empty. If idempotency key exists in the database then
+ * the consent Id list will be not empty.
*
* @param consentIds List of consentIds
- * @return Whether the idempotency key exists
+ * @return Whether the list is not empty
*/
- private static boolean isIdempotencyKeyExists(ArrayList consentIds) {
+ private static boolean isListNotEmpty(ArrayList consentIds) {
return consentIds.size() > 0;
}
+ /**
+ * Method to compare the client ID sent in the request and client id retrieved from the database.
+ *
+ * @param requestClientID Client ID sent in the request
+ * @param dbClientId client ID retrieved from the database
+ * @return Whether JSON client Ids are equal
+ */
+ private static boolean isClientIdsMatching(String requestClientID, String dbClientId) {
+
+ return requestClientID.equals(dbClientId);
+ }
+
/**
* Method to compare whether JSON payloads are equal.
*
@@ -159,8 +180,7 @@ protected static boolean isRequestReceivedWithinAllowedTime(long createdTime) {
if (createdTime == 0L) {
return false;
}
- String allowedTimeDuration = (String) parser.getConfiguration()
- .get(IDEMPOTENCY_ALLOWED_TIME);
+ String allowedTimeDuration = (String) configs.get(IDEMPOTENCY_ALLOWED_TIME);
if (allowedTimeDuration != null) {
OffsetDateTime createdDate = OffsetDateTime.parse(convertToISO8601(createdTime));
OffsetDateTime currDate = OffsetDateTime.now(createdDate.getOffset());
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidatorTests.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidatorTests.java
index 8ed8ee7d..9c4b4f79 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidatorTests.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidatorTests.java
@@ -50,6 +50,7 @@ public class IdempotencyValidatorTests {
private Map configs;
private static final String IDEMPOTENCY_IS_ENABLED = "Consent.Idempotency.Enabled";
private static final String IDEMPOTENCY_ALLOWED_TIME = "Consent.Idempotency.AllowedTimeDuration";
+ private static final String CLIENT_ID = "testClientId";
private static final String PAYLOAD = "{\n" +
" \"Data\": {\n" +
@@ -139,7 +140,7 @@ public void testValidateIdempotency() throws ConsentManagementException {
Mockito.doReturn(getConsent(offsetDateTime.toEpochSecond())).when(consentCoreServiceImpl)
.getDetailedConsent(Mockito.anyString());
IdempotencyValidationResult result = IdempotencyValidator.validateIdempotency("IdempotencyKey",
- "123456", PAYLOAD);
+ "123456", PAYLOAD, CLIENT_ID);
Assert.assertTrue(result.isIdempotent());
Assert.assertTrue(result.isValid());
@@ -149,21 +150,24 @@ public void testValidateIdempotency() throws ConsentManagementException {
@Test
public void testValidateIdempotencyWithoutIdempotencyKeyName() {
- IdempotencyValidationResult result = IdempotencyValidator.validateIdempotency(null, "", "");
+ IdempotencyValidationResult result = IdempotencyValidator
+ .validateIdempotency(null, "", "", CLIENT_ID);
Assert.assertFalse(result.isIdempotent());
}
@Test
public void testValidateIdempotencyWithoutIdempotencyKeyValue() {
- IdempotencyValidationResult result = IdempotencyValidator.validateIdempotency("IdempotencyKey", null, "");
+ IdempotencyValidationResult result = IdempotencyValidator
+ .validateIdempotency("IdempotencyKey", null, "", CLIENT_ID);
Assert.assertFalse(result.isIdempotent());
}
@Test
public void testValidateIdempotencyWithoutRequest() {
- IdempotencyValidationResult result = IdempotencyValidator.validateIdempotency("IdempotencyKey", "123456", "");
+ IdempotencyValidationResult result = IdempotencyValidator
+ .validateIdempotency("IdempotencyKey", "123456", "", CLIENT_ID);
Assert.assertFalse(result.isIdempotent());
}
@@ -174,7 +178,7 @@ public void testValidateIdempotencyRetrievingAttributesWithException() throws Co
Mockito.doThrow(ConsentManagementException.class).when(consentCoreServiceImpl)
.getConsentIdByConsentAttributeNameAndValue(Mockito.anyString(), Mockito.anyString());
IdempotencyValidationResult result = IdempotencyValidator.validateIdempotency("IdempotencyKey",
- "123456", "test");
+ "123456", "test", CLIENT_ID);
Assert.assertFalse(result.isIdempotent());
}
@@ -185,7 +189,7 @@ public void testValidateIdempotencyWithoutAttribute() throws ConsentManagementEx
Mockito.doReturn(new ArrayList<>()).when(consentCoreServiceImpl)
.getConsentIdByConsentAttributeNameAndValue(Mockito.anyString(), Mockito.anyString());
IdempotencyValidationResult result = IdempotencyValidator.validateIdempotency("IdempotencyKey",
- "123456", "test");
+ "123456", "test", CLIENT_ID);
Assert.assertFalse(result.isIdempotent());
}
@@ -197,7 +201,20 @@ public void testValidateIdempotencyWithNullConsentRequest() throws ConsentManage
.getConsentIdByConsentAttributeNameAndValue(Mockito.anyString(), Mockito.anyString());
Mockito.doReturn(null).when(consentCoreServiceImpl).getDetailedConsent(Mockito.anyString());
IdempotencyValidationResult result = IdempotencyValidator.validateIdempotency("IdempotencyKey",
- "123456", "test");
+ "123456", "test", CLIENT_ID);
+
+ Assert.assertTrue(result.isIdempotent());
+ Assert.assertFalse(result.isValid());
+ }
+
+ @Test
+ public void testValidateIdempotencyWithNonMatchingClientId() throws ConsentManagementException {
+
+ Mockito.doReturn(consentIdList).when(consentCoreServiceImpl)
+ .getConsentIdByConsentAttributeNameAndValue(Mockito.anyString(), Mockito.anyString());
+ Mockito.doReturn(null).when(consentCoreServiceImpl).getDetailedConsent(Mockito.anyString());
+ IdempotencyValidationResult result = IdempotencyValidator.validateIdempotency("IdempotencyKey",
+ "123456", "test", "sampleClientID");
Assert.assertTrue(result.isIdempotent());
Assert.assertFalse(result.isValid());
@@ -211,7 +228,7 @@ public void testValidateIdempotencyWithNonMatchingPayload() throws ConsentManage
Mockito.doReturn(getConsent(System.currentTimeMillis())).when(consentCoreServiceImpl)
.getDetailedConsent(Mockito.anyString());
IdempotencyValidationResult result = IdempotencyValidator.validateIdempotency("IdempotencyKey",
- "123456", DIFFERENT_PAYLOAD);
+ "123456", DIFFERENT_PAYLOAD, CLIENT_ID);
Assert.assertTrue(result.isIdempotent());
Assert.assertFalse(result.isValid());
@@ -227,7 +244,7 @@ public void testValidateIdempotencyAfterAllowedTime() throws ConsentManagementEx
Mockito.doReturn(getConsent(offsetDateTime.toEpochSecond())).when(consentCoreServiceImpl)
.getDetailedConsent(Mockito.anyString());
IdempotencyValidationResult result = IdempotencyValidator.validateIdempotency("IdempotencyKey",
- "123456", DIFFERENT_PAYLOAD);
+ "123456", DIFFERENT_PAYLOAD, CLIENT_ID);
Assert.assertTrue(result.isIdempotent());
Assert.assertFalse(result.isValid());
@@ -237,6 +254,7 @@ private DetailedConsentResource getConsent(long createdTime) {
DetailedConsentResource consent = new DetailedConsentResource();
consent.setConsentID(consentId);
consent.setReceipt(PAYLOAD);
+ consent.setClientID(CLIENT_ID);
consent.setCreatedTime(createdTime);
return consent;
}
From 83666b0ce8055727a7932a36e24cb3e6be409bf9 Mon Sep 17 00:00:00 2001
From: Ashirwada
Date: Tue, 5 Mar 2024 17:37:08 +0530
Subject: [PATCH 081/281] Fixed review comments
---
.../extensions/common/idempotency/IdempotencyValidator.java | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
index cea3e252..2562991c 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
@@ -69,16 +69,22 @@ public static IdempotencyValidationResult validateIdempotency(String idempotency
return new IdempotencyValidationResult(false, false, null, null);
}
try {
+ // Retrieve consent ids that have the idempotency key name and value as attribute
ArrayList consentIds = getConsentIdsFromIdempotencyKey(idempotencyKeyName,
idempotencyKeyValue);
+ // Check whether the consent id list is not empty
if (isListNotEmpty(consentIds)) {
log.debug(String.format("Idempotency Key %s exists in the database. Hence this is an idempotent" +
" request", idempotencyKeyValue));
for (String consentId : consentIds) {
DetailedConsentResource consentRequest = consentCoreService.getDetailedConsent(consentId);
if (consentRequest != null) {
+ // Compare the client ID sent in the request and client id retrieved from the database
+ // to validate whether the request is received from the same client
if (isClientIdsMatching(clientId, consentRequest.getClientID())) {
+ // Compare whether JSON payloads are equal
if (isJSONPayloadSimilar(consentRequest.getReceipt(), request)) {
+ // Check whether difference between two dates is less than the configured time
if (isRequestReceivedWithinAllowedTime(consentRequest.getCreatedTime())) {
log.debug("Payloads are similar and request received within allowed time." +
" Hence this is a valid idempotent request");
From f51e3d22692296849a905144fca6c0fd0b607062 Mon Sep 17 00:00:00 2001
From: Ashirwada
Date: Wed, 6 Mar 2024 09:53:08 +0530
Subject: [PATCH 082/281] Fixed review comments
---
.../extensions/common/idempotency/IdempotencyValidator.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
index 2562991c..308b9937 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
@@ -145,7 +145,7 @@ private static ArrayList getConsentIdsFromIdempotencyKey(String idempote
* @return Whether the list is not empty
*/
private static boolean isListNotEmpty(ArrayList consentIds) {
- return consentIds.size() > 0;
+ return !consentIds.isEmpty();
}
/**
From 5c470ec8127d72f7d3ea0fd44f8a2aeb7c4ce680 Mon Sep 17 00:00:00 2001
From: Ashirwada
Date: Wed, 6 Mar 2024 17:14:47 +0530
Subject: [PATCH 083/281] Fixed code review comments
---
.../idempotency/IdempotencyConstants.java | 28 ++++++++++
.../idempotency/IdempotencyValidator.java | 51 +++++++++----------
.../IdempotencyValidatorTests.java | 47 +++++++----------
3 files changed, 72 insertions(+), 54 deletions(-)
create mode 100644 open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyConstants.java
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyConstants.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyConstants.java
new file mode 100644
index 00000000..d0b8f988
--- /dev/null
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyConstants.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
+ *
+ * This software is the property of WSO2 LLC. and its suppliers, if any.
+ * Dissemination of any information or reproduction of any material contained
+ * herein in any form is strictly forbidden, unless permitted by WSO2 expressly.
+ * You may not alter or remove any copyright or other notice from copies of this content.
+ */
+
+package com.wso2.openbanking.accelerator.consent.extensions.common.idempotency;
+
+/**
+ * Constants related to idempotency operations.
+ */
+public class IdempotencyConstants {
+
+ public static final String IDEMPOTENCY_IS_ENABLED = "Consent.Idempotency.Enabled";
+ public static final String IDEMPOTENCY_ALLOWED_TIME = "Consent.Idempotency.AllowedTimeDuration";
+ public static final String ERROR_PAYLOAD_NOT_SIMILAR = "Payloads are not similar. Hence this is not a valid" +
+ " idempotent request";
+ public static final String ERROR_AFTER_ALLOWED_TIME = "Request received after the allowed time., Hence this is" +
+ " not a valid idempotent request";
+ public static final String ERROR_MISMATCHING_CLIENT_ID = "Client ID sent in the request does not match with the" +
+ " client ID in the retrieved consent. Hence this is not a valid idempotent request";
+ public static final String ERROR_NO_CONSENT_DETAILS = "No consent details found for the consent ID, Hence this" +
+ " is not a valid idempotent request";
+ public static final String JSON_COMPARING_ERROR = "Error occurred while comparing JSON payloads";
+}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
index 308b9937..7291b20a 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
@@ -46,9 +46,6 @@ public class IdempotencyValidator {
private static final Map configs = OpenBankingConfigParser.getInstance().getConfiguration();
private static final ConsentCoreService consentCoreService = ConsentExtensionsDataHolder.getInstance()
.getConsentCoreService();
- private static final String IDEMPOTENCY_IS_ENABLED = "Consent.Idempotency.Enabled";
- private static final String IDEMPOTENCY_ALLOWED_TIME = "Consent.Idempotency.AllowedTimeDuration";
-
/**
* Method to check whether the request is idempotent.
@@ -61,10 +58,13 @@ public class IdempotencyValidator {
* @return IdempotencyValidationResult
*/
public static IdempotencyValidationResult validateIdempotency(String idempotencyKeyName, String idempotencyKeyValue,
- String request, String clientId) {
- if (Boolean.parseBoolean((String) configs.get(IDEMPOTENCY_IS_ENABLED))) {
- if (idempotencyKeyValue == null || request.isEmpty()) {
- log.debug("Idempotency Key Value or Request is empty. Hence cannot proceed with " +
+ String request, String clientId)
+ throws ConsentManagementException {
+
+ if (Boolean.parseBoolean((configs.get(IdempotencyConstants.IDEMPOTENCY_IS_ENABLED)).toString())) {
+ // If idempotency key name, value or request is empty then cannot proceed with idempotency validation
+ if (idempotencyKeyName == null || idempotencyKeyValue == null || request.isEmpty() || clientId == null) {
+ log.debug("Idempotency Key , NameValue, Client ID or Request is empty. Hence cannot proceed with " +
"idempotency validation");
return new IdempotencyValidationResult(false, false, null, null);
}
@@ -82,38 +82,37 @@ public static IdempotencyValidationResult validateIdempotency(String idempotency
// Compare the client ID sent in the request and client id retrieved from the database
// to validate whether the request is received from the same client
if (isClientIdsMatching(clientId, consentRequest.getClientID())) {
- // Compare whether JSON payloads are equal
- if (isJSONPayloadSimilar(consentRequest.getReceipt(), request)) {
- // Check whether difference between two dates is less than the configured time
- if (isRequestReceivedWithinAllowedTime(consentRequest.getCreatedTime())) {
+ // Check whether difference between two dates is less than the configured time
+ if (isRequestReceivedWithinAllowedTime(consentRequest.getCreatedTime())) {
+ // Compare whether JSON payloads are equal
+ if (isJSONPayloadSimilar(consentRequest.getReceipt(), request)) {
log.debug("Payloads are similar and request received within allowed time." +
" Hence this is a valid idempotent request");
return new IdempotencyValidationResult(true, true,
consentRequest, consentId);
} else {
- log.debug("Payloads are similar and request is not within allowed time." +
- " Hence this is not a valid idempotent request");
- return new IdempotencyValidationResult(true, false, null, null);
+ log.debug(IdempotencyConstants.ERROR_PAYLOAD_NOT_SIMILAR);
+ throw new ConsentManagementException(IdempotencyConstants
+ .ERROR_PAYLOAD_NOT_SIMILAR);
}
} else {
- log.debug("Payloads are not similar, Hence this is not a valid idempotent " +
- "request");
- return new IdempotencyValidationResult(true, false, null, null);
+ log.debug(IdempotencyConstants.ERROR_AFTER_ALLOWED_TIME);
+ throw new ConsentManagementException(IdempotencyConstants
+ .ERROR_AFTER_ALLOWED_TIME);
}
} else {
- log.debug("Client ID sent in the request does not match with the client ID in the" +
- " retrieved consent. Hence this is not a valid idempotent request");
- return new IdempotencyValidationResult(true, false, null, null);
+ log.debug(IdempotencyConstants.ERROR_MISMATCHING_CLIENT_ID);
+ throw new ConsentManagementException(IdempotencyConstants.ERROR_MISMATCHING_CLIENT_ID);
}
} else {
- log.debug("No consent details found for the consent ID, Hence this is not a " +
- "valid idempotent request");
- return new IdempotencyValidationResult(true, false, null, null);
+ log.debug(IdempotencyConstants.ERROR_NO_CONSENT_DETAILS);
+ throw new ConsentManagementException(IdempotencyConstants.ERROR_NO_CONSENT_DETAILS);
}
}
}
- } catch (IOException | ConsentManagementException e) {
- log.error("Error occurred while comparing JSON payloads", e);
+ } catch (IOException e) {
+ log.error(IdempotencyConstants.JSON_COMPARING_ERROR, e);
+ throw new ConsentManagementException(IdempotencyConstants.JSON_COMPARING_ERROR);
}
}
return new IdempotencyValidationResult(false, false, null, null);
@@ -186,7 +185,7 @@ protected static boolean isRequestReceivedWithinAllowedTime(long createdTime) {
if (createdTime == 0L) {
return false;
}
- String allowedTimeDuration = (String) configs.get(IDEMPOTENCY_ALLOWED_TIME);
+ String allowedTimeDuration = (String) configs.get(IdempotencyConstants.IDEMPOTENCY_ALLOWED_TIME);
if (allowedTimeDuration != null) {
OffsetDateTime createdDate = OffsetDateTime.parse(convertToISO8601(createdTime));
OffsetDateTime currDate = OffsetDateTime.now(createdDate.getOffset());
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidatorTests.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidatorTests.java
index 9c4b4f79..1aefc909 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidatorTests.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidatorTests.java
@@ -149,7 +149,7 @@ public void testValidateIdempotency() throws ConsentManagementException {
}
@Test
- public void testValidateIdempotencyWithoutIdempotencyKeyName() {
+ public void testValidateIdempotencyWithoutIdempotencyKeyName() throws ConsentManagementException {
IdempotencyValidationResult result = IdempotencyValidator
.validateIdempotency(null, "", "", CLIENT_ID);
@@ -157,7 +157,7 @@ public void testValidateIdempotencyWithoutIdempotencyKeyName() {
}
@Test
- public void testValidateIdempotencyWithoutIdempotencyKeyValue() {
+ public void testValidateIdempotencyWithoutIdempotencyKeyValue() throws ConsentManagementException {
IdempotencyValidationResult result = IdempotencyValidator
.validateIdempotency("IdempotencyKey", null, "", CLIENT_ID);
@@ -165,7 +165,7 @@ public void testValidateIdempotencyWithoutIdempotencyKeyValue() {
}
@Test
- public void testValidateIdempotencyWithoutRequest() {
+ public void testValidateIdempotencyWithoutRequest() throws ConsentManagementException {
IdempotencyValidationResult result = IdempotencyValidator
.validateIdempotency("IdempotencyKey", "123456", "", CLIENT_ID);
@@ -194,60 +194,51 @@ public void testValidateIdempotencyWithoutAttribute() throws ConsentManagementEx
Assert.assertFalse(result.isIdempotent());
}
- @Test
+ @Test(expectedExceptions = ConsentManagementException.class)
public void testValidateIdempotencyWithNullConsentRequest() throws ConsentManagementException {
Mockito.doReturn(consentIdList).when(consentCoreServiceImpl)
.getConsentIdByConsentAttributeNameAndValue(Mockito.anyString(), Mockito.anyString());
Mockito.doReturn(null).when(consentCoreServiceImpl).getDetailedConsent(Mockito.anyString());
- IdempotencyValidationResult result = IdempotencyValidator.validateIdempotency("IdempotencyKey",
+ IdempotencyValidator.validateIdempotency("IdempotencyKey",
"123456", "test", CLIENT_ID);
-
- Assert.assertTrue(result.isIdempotent());
- Assert.assertFalse(result.isValid());
}
- @Test
+ @Test(expectedExceptions = ConsentManagementException.class)
public void testValidateIdempotencyWithNonMatchingClientId() throws ConsentManagementException {
Mockito.doReturn(consentIdList).when(consentCoreServiceImpl)
.getConsentIdByConsentAttributeNameAndValue(Mockito.anyString(), Mockito.anyString());
Mockito.doReturn(null).when(consentCoreServiceImpl).getDetailedConsent(Mockito.anyString());
- IdempotencyValidationResult result = IdempotencyValidator.validateIdempotency("IdempotencyKey",
+ IdempotencyValidator.validateIdempotency("IdempotencyKey",
"123456", "test", "sampleClientID");
-
- Assert.assertTrue(result.isIdempotent());
- Assert.assertFalse(result.isValid());
}
- @Test
- public void testValidateIdempotencyWithNonMatchingPayload() throws ConsentManagementException {
+ @Test(expectedExceptions = ConsentManagementException.class)
+ public void testValidateIdempotencyAfterAllowedTime() throws ConsentManagementException {
+
+ OffsetDateTime offsetDateTime = OffsetDateTime.now().minusHours(2);
Mockito.doReturn(consentIdList).when(consentCoreServiceImpl)
.getConsentIdByConsentAttributeNameAndValue(Mockito.anyString(), Mockito.anyString());
- Mockito.doReturn(getConsent(System.currentTimeMillis())).when(consentCoreServiceImpl)
+ Mockito.doReturn(getConsent(offsetDateTime.toEpochSecond())).when(consentCoreServiceImpl)
.getDetailedConsent(Mockito.anyString());
- IdempotencyValidationResult result = IdempotencyValidator.validateIdempotency("IdempotencyKey",
- "123456", DIFFERENT_PAYLOAD, CLIENT_ID);
-
- Assert.assertTrue(result.isIdempotent());
- Assert.assertFalse(result.isValid());
+ IdempotencyValidator.validateIdempotency("IdempotencyKey",
+ "123456", PAYLOAD, CLIENT_ID);
}
- @Test
- public void testValidateIdempotencyAfterAllowedTime() throws ConsentManagementException {
+ @Test(expectedExceptions = ConsentManagementException.class)
+ public void testValidateIdempotencyWithNonMatchingPayload() throws ConsentManagementException {
- OffsetDateTime offsetDateTime = OffsetDateTime.now().minusHours(2);
+ OffsetDateTime offsetDateTime = OffsetDateTime.now();
Mockito.doReturn(consentIdList).when(consentCoreServiceImpl)
.getConsentIdByConsentAttributeNameAndValue(Mockito.anyString(), Mockito.anyString());
Mockito.doReturn(getConsent(offsetDateTime.toEpochSecond())).when(consentCoreServiceImpl)
.getDetailedConsent(Mockito.anyString());
- IdempotencyValidationResult result = IdempotencyValidator.validateIdempotency("IdempotencyKey",
- "123456", DIFFERENT_PAYLOAD, CLIENT_ID);
+ IdempotencyValidator.validateIdempotency("IdempotencyKey", "123456",
+ DIFFERENT_PAYLOAD, CLIENT_ID);
- Assert.assertTrue(result.isIdempotent());
- Assert.assertFalse(result.isValid());
}
private DetailedConsentResource getConsent(long createdTime) {
From 336d1c529ce441fdf011c9ecbf98e2e45269d154 Mon Sep 17 00:00:00 2001
From: Ashirwada
Date: Thu, 7 Mar 2024 14:09:00 +0530
Subject: [PATCH 084/281] Fixed code review comments
---
.../common/idempotency/IdempotencyValidator.java | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
index 7291b20a..170cc54b 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java
@@ -72,8 +72,9 @@ public static IdempotencyValidationResult validateIdempotency(String idempotency
// Retrieve consent ids that have the idempotency key name and value as attribute
ArrayList consentIds = getConsentIdsFromIdempotencyKey(idempotencyKeyName,
idempotencyKeyValue);
- // Check whether the consent id list is not empty
- if (isListNotEmpty(consentIds)) {
+ // Check whether the consent id list is not empty. If idempotency key exists in the database then
+ // the consent Id list will be not empty.
+ if (!consentIds.isEmpty()) {
log.debug(String.format("Idempotency Key %s exists in the database. Hence this is an idempotent" +
" request", idempotencyKeyValue));
for (String consentId : consentIds) {
@@ -136,17 +137,6 @@ private static ArrayList getConsentIdsFromIdempotencyKey(String idempote
}
}
- /**
- * Method to check whether the consent ID list is not empty. If idempotency key exists in the database then
- * the consent Id list will be not empty.
- *
- * @param consentIds List of consentIds
- * @return Whether the list is not empty
- */
- private static boolean isListNotEmpty(ArrayList consentIds) {
- return !consentIds.isEmpty();
- }
-
/**
* Method to compare the client ID sent in the request and client id retrieved from the database.
*
From 5b18a4c4cb631966cb1ea6503823f144d1818ef8 Mon Sep 17 00:00:00 2001
From: Rivindu
Date: Thu, 7 Mar 2024 16:48:10 +0530
Subject: [PATCH 085/281] Add isExpired method as a deprecated method
---
.../util/CertificateValidationUtils.java | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/util/CertificateValidationUtils.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/util/CertificateValidationUtils.java
index c2d34e42..f1238d1e 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/util/CertificateValidationUtils.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/util/CertificateValidationUtils.java
@@ -71,6 +71,22 @@ private CertificateValidationUtils() {
// Adding a private constructor to hide the implicit public one.
}
+ /**
+ * @deprecated use com.wso2.openbanking.accelerator.common.util.CertificateUtils.isExpired() instead
+ */
+ @Deprecated
+ public static boolean isExpired(X509Certificate peerCertificate) {
+ try {
+ peerCertificate.checkValidity();
+ } catch (CertificateException e) {
+ LOG.error("Certificate with the serial number " +
+ peerCertificate.getSerialNumber() + " issued by the CA " +
+ peerCertificate.getIssuerDN().toString() + " is expired. Caused by, " + e.getMessage());
+ return true;
+ }
+ return false;
+ }
+
/**
* Get issuer certificate from the truststore.
*
From 2e54ae5ed3a016314b70ebde41cee0dae7236a00 Mon Sep 17 00:00:00 2001
From: Ashirwada
Date: Fri, 8 Mar 2024 10:45:27 +0530
Subject: [PATCH 086/281] Fixed code review comments
---
.../repository/conf/open-banking.xml.j2 | 78 -------------------
1 file changed, 78 deletions(-)
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2 b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
index 5726160a..64989455 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking.xml.j2
@@ -1034,84 +1034,6 @@
{% endif %}
-
-
- {% if open_banking.distributed_cache.enabled is defined %}
- {{open_banking.distributed_cache.enabled}}
- {% else %}
- false
- {% endif %}
- {% if open_banking.distributed_cache.host_name is defined %}
- {{open_banking.distributed_cache.host_name}}
- {% else %}
- localhost
- {% endif %}
- {% if open_banking.distributed_cache.port is defined %}
- {{open_banking.distributed_cache.port}}
- {% else %}
- 5701
- {% endif %}
- {% if ( (open_banking.distributed_cache.discovery_mechanism is defined) and (open_banking.distributed_cache.discovery_mechanism == "TCP") ) %}
- {{open_banking.distributed_cache.discovery_mechanism}}
- {% if open_banking.distributed_cache.members is defined %}
-
- {% for member in open_banking.distributed_cache.members %}
- {{member}}
- {% endfor %}
-
- {% else %}
-
- {% endif %}
- {% else %}
- Multicast
- {% if open_banking.distributed_cache.multicast_group is defined %}
- {{open_banking.distributed_cache.multicast_group}}
- {% else %}
- 224.2.2.3
- {% endif %}
- {% if open_banking.distributed_cache.multicast_port is defined %}
- {{open_banking.distributed_cache.multicast_port}}
- {% else %}
- 54321
- {% endif %}
- {% if open_banking.distributed_cache.trusted_interfaces is defined %}
-
- {% for trusted_interface in open_banking.distributed_cache.trusted_interfaces %}
- {{trusted_interface}}
- {% endfor %}
-
- {% else %}
-
- {% endif %}
- {% endif %}
-
- {% if open_banking.distributed_cache.properties.max_heartbeat is defined %}
- {{open_banking.distributed_cache.properties.max_heartbeat}}
- {% else %}
- 600
- {% endif %}
- {% if open_banking.distributed_cache.properties.max_master_confirmation is defined %}
- {{open_banking.distributed_cache.properties.max_master_confirmation}}
- {% else %}
- 900
- {% endif %}
- {% if open_banking.distributed_cache.properties.merge_first_run_delay is defined %}
- {{open_banking.distributed_cache.properties.merge_first_run_delay}}
- {% else %}
- 60
- {% endif %}
- {% if open_banking.distributed_cache.properties.merge_next_run_delay is defined %}
- {{open_banking.distributed_cache.properties.merge_next_run_delay}}
- {% else %}
- 30
- {% endif %}
- {% if open_banking.distributed_cache.properties.logging_type is defined %}
- {{open_banking.distributed_cache.properties.logging_type}}
- {% else %}
- none
- {% endif %}
-
-
{% for worker in open_banking.identity.authentication.worker %}
Date: Fri, 8 Mar 2024 15:13:28 +0530
Subject: [PATCH 087/281] Implementation of the persistence flow
---
.../impl/DefaultConsentPersistStep.java | 60 ++++++++++++++++---
.../AcceleratorConsentExtensionFactory.java | 47 ---------------
2 files changed, 53 insertions(+), 54 deletions(-)
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/DefaultConsentPersistStep.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/DefaultConsentPersistStep.java
index a0cc599e..55c10a3a 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/DefaultConsentPersistStep.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/DefaultConsentPersistStep.java
@@ -20,18 +20,21 @@
package com.wso2.openbanking.accelerator.consent.extensions.authorize.impl;
import com.wso2.openbanking.accelerator.common.exception.ConsentManagementException;
-import com.wso2.openbanking.accelerator.consent.extensions.authorize.impl.handler.persist.ConsentPersistenceHandler;
import com.wso2.openbanking.accelerator.consent.extensions.authorize.model.ConsentData;
import com.wso2.openbanking.accelerator.consent.extensions.authorize.model.ConsentPersistData;
import com.wso2.openbanking.accelerator.consent.extensions.authorize.model.ConsentPersistStep;
import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentException;
+import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentExtensionConstants;
import com.wso2.openbanking.accelerator.consent.extensions.common.ResponseStatus;
-import com.wso2.openbanking.accelerator.consent.extensions.common.factory.AcceleratorConsentExtensionFactory;
import com.wso2.openbanking.accelerator.consent.extensions.internal.ConsentExtensionsDataHolder;
import com.wso2.openbanking.accelerator.consent.mgt.dao.models.ConsentResource;
+import net.minidev.json.JSONArray;
+import net.minidev.json.JSONObject;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import java.util.ArrayList;
+
/**
* Consent persist step default implementation.
@@ -66,16 +69,59 @@ public void execute(ConsentPersistData consentPersistData) throws ConsentExcepti
"Auth resource not available in consent data");
}
- //Bind the user and accounts with the consent
- String type = consentResource.getConsentType();
- ConsentPersistenceHandler consentPersistenceHandler = AcceleratorConsentExtensionFactory
- .getConsentPersistenceHandler(type);
+ consentPersist(consentPersistData, consentResource);
- consentPersistenceHandler.consentPersist(consentPersistData, consentResource);
} catch (ConsentManagementException e) {
throw new ConsentException(ResponseStatus.INTERNAL_SERVER_ERROR,
"Exception occured while persisting consent");
}
}
+
+ /**
+ * Abstract method defined to handle consent persistence based on the consent type.
+ *
+ * @param consentPersistData Consent Persist Data Object
+ * @param consentResource Consent Resource Object
+ * @throws ConsentManagementException
+ */
+ public static void consentPersist(ConsentPersistData consentPersistData, ConsentResource consentResource)
+ throws ConsentManagementException {
+
+ ConsentData consentData = consentPersistData.getConsentData();
+
+ JSONObject payload = consentPersistData.getPayload();
+
+ if (payload.get("accountIds") == null || !(payload.get("accountIds") instanceof JSONArray)) {
+ log.error("Account IDs not available in persist request");
+ throw new ConsentException(ResponseStatus.BAD_REQUEST,
+ "Account IDs not available in persist request");
+ }
+
+ JSONArray accountIds = (JSONArray) payload.get("accountIds");
+ ArrayList accountIdsString = new ArrayList<>();
+ for (Object account : accountIds) {
+ if (!(account instanceof String)) {
+ log.error("Account IDs format error in persist request");
+ throw new ConsentException(ResponseStatus.BAD_REQUEST,
+ "Account IDs format error in persist request");
+ }
+ accountIdsString.add((String) account);
+ }
+ String consentStatus;
+ String authStatus;
+
+ if (consentPersistData.getApproval()) {
+ consentStatus = ConsentExtensionConstants.AUTHORIZED_STATUS;
+ authStatus = ConsentExtensionConstants.AUTHORIZED_STATUS;
+ } else {
+ consentStatus = ConsentExtensionConstants.REJECTED_STATUS;
+ authStatus = ConsentExtensionConstants.REJECTED_STATUS;
+ }
+
+ ConsentExtensionsDataHolder.getInstance().getConsentCoreService()
+ .bindUserAccountsToConsent(consentResource, consentData.getUserId(),
+ consentData.getAuthResource().getAuthorizationID(), accountIdsString, authStatus,
+ consentStatus);
+ }
}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/factory/AcceleratorConsentExtensionFactory.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/factory/AcceleratorConsentExtensionFactory.java
index 47a00f48..225f2451 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/factory/AcceleratorConsentExtensionFactory.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/factory/AcceleratorConsentExtensionFactory.java
@@ -21,10 +21,6 @@
import com.wso2.openbanking.accelerator.consent.extensions.authorize.impl.handler.persist.CofConsentPersistenceHandler;
import com.wso2.openbanking.accelerator.consent.extensions.authorize.impl.handler.persist.ConsentPersistenceHandler;
import com.wso2.openbanking.accelerator.consent.extensions.authorize.impl.handler.persist.PaymentConsentPersistenceHandler;
-import com.wso2.openbanking.accelerator.consent.extensions.authorize.impl.handler.retrieval.AccountConsentRetrievalHandler;
-import com.wso2.openbanking.accelerator.consent.extensions.authorize.impl.handler.retrieval.CofConsentRetrievalHandler;
-import com.wso2.openbanking.accelerator.consent.extensions.authorize.impl.handler.retrieval.ConsentRetrievalHandler;
-import com.wso2.openbanking.accelerator.consent.extensions.authorize.impl.handler.retrieval.PaymentConsentRetrievalHandler;
import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentExtensionConstants;
import com.wso2.openbanking.accelerator.consent.extensions.manage.impl.AccountConsentManageRequestHandler;
import com.wso2.openbanking.accelerator.consent.extensions.manage.impl.CofConsentRequestHandler;
@@ -65,47 +61,4 @@ public static ConsentManageRequestHandler getConsentManageRequestValidator(Strin
return consentManageRequestHandler;
}
-
- /**
- * Method to get the Consent Authorize Handler.
- *
- * @param type Type of the request
- * @return ConsentAuthorizeHandler
- */
- public static ConsentRetrievalHandler getConsentRetrievalHandler(String type) {
-
- ConsentRetrievalHandler consentRetrieveHandler = null;
-
- if (type.equalsIgnoreCase(ConsentExtensionConstants.ACCOUNTS)) {
- consentRetrieveHandler = new AccountConsentRetrievalHandler();
- } else if (type.equalsIgnoreCase(ConsentExtensionConstants.PAYMENTS)) {
- consentRetrieveHandler = new PaymentConsentRetrievalHandler();
- } else if (type.equalsIgnoreCase(ConsentExtensionConstants.FUNDSCONFIRMATIONS)) {
- consentRetrieveHandler = new CofConsentRetrievalHandler();
- }
- return consentRetrieveHandler;
-
- }
-
- /**
- * Method to get the Consent Persistence Handler.
- *
- * @param type Type of the request
- * @return ConsentPersistenceHandler
- */
- public static ConsentPersistenceHandler getConsentPersistenceHandler(String type) {
-
- ConsentPersistenceHandler consentPersistenceHandler = null;
-
- if (ConsentExtensionConstants.ACCOUNTS.equalsIgnoreCase(type)) {
- consentPersistenceHandler = new AccountConsentPersistenceHandler();
- } else if (ConsentExtensionConstants.PAYMENTS.equalsIgnoreCase(type)) {
- consentPersistenceHandler = new PaymentConsentPersistenceHandler();
- } else if (ConsentExtensionConstants.FUNDSCONFIRMATIONS.equalsIgnoreCase(type)) {
- consentPersistenceHandler = new CofConsentPersistenceHandler();
- }
- return consentPersistenceHandler;
-
- }
-
}
From 2105df81dc4c6ae07bae7df1b5e49f4b19b19c5a Mon Sep 17 00:00:00 2001
From: kalpana
Date: Fri, 8 Mar 2024 15:23:45 +0530
Subject: [PATCH 088/281] Unit test for persistence flow
---
.../common/ConsentExtensionConstants.java | 1 +
.../flow/ConsentPersistStepTests.java | 220 +++++++++++++++
.../authservlet/impl/AuthServletTest.java | 181 +++++++++++++
.../utils/AuthServletTestConstants.java | 256 ++++++++++++++++++
.../ConsentAuthorizeTestConstants.java | 112 +++++++-
.../src/test/resources/testng.xml | 2 +
6 files changed, 764 insertions(+), 8 deletions(-)
create mode 100644 open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/persistence/flow/ConsentPersistStepTests.java
create mode 100644 open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authservlet/impl/AuthServletTest.java
create mode 100644 open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/utils/AuthServletTestConstants.java
rename open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/{authorize/vrp/retrieval/flow => utils}/ConsentAuthorizeTestConstants.java (79%)
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/ConsentExtensionConstants.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/ConsentExtensionConstants.java
index 4b05690b..65c1fae4 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/ConsentExtensionConstants.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/ConsentExtensionConstants.java
@@ -208,4 +208,5 @@ public class ConsentExtensionConstants {
public static final Object CONTROL_PARAMETER_AMOUNT_TITLE = "Maximum payment amount per ";
public static final String VRP_ACCOUNT = "vrpAccount";
public static final Object CONTROL_PARAMETER_VALID_FROM_DATE_TITLE = "Valid from date and time";
+ public static final String ACCOUNT_IDS = "accountIds";
}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/persistence/flow/ConsentPersistStepTests.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/persistence/flow/ConsentPersistStepTests.java
new file mode 100644
index 00000000..630046e9
--- /dev/null
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/persistence/flow/ConsentPersistStepTests.java
@@ -0,0 +1,220 @@
+/**
+ * Copyright (c) 2021-2022, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
+ *
+ * This software is the property of WSO2 LLC. and its suppliers, if any.
+ * Dissemination of any information or reproduction of any material contained
+ * herein in any form is strictly forbidden, unless permitted by WSO2 expressly.
+ * You may not alter or remove any copyright or other notice from copies of this content.
+ */
+
+package com.wso2.openbanking.accelerator.consent.extensions.authorize.vrp.persistence.flow;
+
+import com.wso2.openbanking.accelerator.common.config.OpenBankingConfigParser;
+import com.wso2.openbanking.accelerator.common.util.CarbonUtils;
+import com.wso2.openbanking.accelerator.consent.extensions.authorize.impl.DefaultConsentPersistStep;
+import com.wso2.openbanking.accelerator.consent.extensions.authorize.model.ConsentData;
+import com.wso2.openbanking.accelerator.consent.extensions.authorize.model.ConsentPersistData;
+import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentException;
+import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentServiceUtil;
+import com.wso2.openbanking.accelerator.consent.extensions.utils.ConsentAuthorizeTestConstants;
+import com.wso2.openbanking.accelerator.consent.extensions.utils.ConsentExtensionTestUtils;
+import com.wso2.openbanking.accelerator.consent.mgt.dao.models.ConsentResource;
+import com.wso2.openbanking.accelerator.consent.mgt.service.impl.ConsentCoreServiceImpl;
+import net.minidev.json.JSONObject;
+import net.minidev.json.parser.JSONParser;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.testng.IObjectFactory;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.ObjectFactory;
+import org.testng.annotations.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.powermock.api.mockito.PowerMockito.when;
+
+/**
+ * Test class for Consent Persistence.
+ */
+@PrepareForTest({OpenBankingConfigParser.class, ConsentServiceUtil.class})
+@PowerMockIgnore({"com.wso2.openbanking.accelerator.consent.extensions.common.*", "net.minidev.*",
+ "jdk.internal.reflect.*"})
+public class ConsentPersistStepTests {
+
+ @Mock
+ OpenBankingConfigParser openBankingConfigParserMock;
+ @Mock
+ private static DefaultConsentPersistStep consentPersistStep;
+ @Mock
+ private static ConsentPersistData consentPersistDataMock;
+ @Mock
+ private static ConsentData consentDataMock;
+ @Mock
+ private static ConsentResource consentResourceMock;
+ @Mock
+ ConsentCoreServiceImpl consentCoreServiceMock;
+ private static Map configMap;
+ JSONParser parser = new JSONParser(JSONParser.MODE_PERMISSIVE);
+
+ @BeforeClass
+ public void initTest() throws ReflectiveOperationException {
+
+ MockitoAnnotations.initMocks(this);
+
+ consentPersistStep = new DefaultConsentPersistStep();
+ consentPersistDataMock = mock(ConsentPersistData.class);
+ consentDataMock = mock(ConsentData.class);
+ consentResourceMock = mock(ConsentResource.class);
+ consentCoreServiceMock = mock(ConsentCoreServiceImpl.class);
+
+ configMap = new HashMap<>();
+ configMap.put("ErrorURL", "https://localhost:8243/error");
+
+ //to execute util class initialization
+ new CarbonUtils();
+ System.setProperty("some.property", "property.value");
+ System.setProperty("carbon.home", ".");
+ ConsentExtensionTestUtils.injectEnvironmentVariable("CARBON_HOME", ".");
+ }
+
+ @ObjectFactory
+ public IObjectFactory getObjectFactory() {
+
+ return new org.powermock.modules.testng.PowerMockObjectFactory();
+ }
+
+ @BeforeMethod
+ public void initMethod() {
+
+ openBankingConfigParserMock = mock(OpenBankingConfigParser.class);
+
+ PowerMockito.mockStatic(OpenBankingConfigParser.class);
+ when(OpenBankingConfigParser.getInstance()).thenReturn(openBankingConfigParserMock);
+
+ PowerMockito.mockStatic(ConsentServiceUtil.class);
+ when(ConsentServiceUtil.getConsentService()).thenReturn(consentCoreServiceMock);
+ }
+
+ @Test(priority = 1, expectedExceptions = ConsentException.class)
+ public void testConsentPersistWithoutConsentId() {
+
+ doReturn(consentDataMock).when(consentPersistDataMock).getConsentData();
+ consentPersistStep.execute(consentPersistDataMock);
+ }
+
+ @Test(priority = 3, expectedExceptions = ConsentException.class)
+ public void testConsentPersistWithoutAuthResource() {
+
+ doReturn(consentDataMock).when(consentPersistDataMock).getConsentData();
+ doReturn("1234").when(consentDataMock).getConsentId();
+ doReturn(consentResourceMock).when(consentDataMock).getConsentResource();
+
+ consentPersistStep.execute(consentPersistDataMock);
+ }
+
+ @Test(priority = 6, expectedExceptions = ConsentException.class)
+ public void testAccountConsentPersistWithoutAccountIDs() throws Exception {
+
+ doReturn(consentDataMock).when(consentPersistDataMock).getConsentData();
+ doReturn(ConsentAuthorizeTestConstants.CONSENT_ID).when(consentDataMock).getConsentId();
+ doReturn(ConsentAuthorizeTestConstants.USER_ID).when(consentDataMock).getUserId();
+ doReturn(ConsentAuthorizeTestConstants.CLIENT_ID).when(consentDataMock).getClientId();
+ doReturn(consentResourceMock).when(consentDataMock).getConsentResource();
+ doReturn(ConsentAuthorizeTestConstants.getAuthResource()).when(consentDataMock).getAuthResource();
+ doReturn(ConsentAuthorizeTestConstants.ACCOUNTS).when(consentResourceMock).getConsentType();
+ doReturn(true).when(consentPersistDataMock).getApproval();
+
+ JSONObject payload = (JSONObject) parser
+ .parse(ConsentAuthorizeTestConstants.ACCOUNT_PERSIST_PAYLOAD_WITHOUT_ACCOUNT_ID);
+ doReturn(payload).when(consentPersistDataMock).getPayload();
+
+ consentPersistStep.execute(consentPersistDataMock);
+ }
+
+ @Test(priority = 7, expectedExceptions = ConsentException.class)
+ public void testAccountConsentPersistWithNonStringAccountIDs() throws Exception {
+
+ doReturn(consentDataMock).when(consentPersistDataMock).getConsentData();
+ doReturn(ConsentAuthorizeTestConstants.CONSENT_ID).when(consentDataMock).getConsentId();
+ doReturn(ConsentAuthorizeTestConstants.USER_ID).when(consentDataMock).getUserId();
+ doReturn(ConsentAuthorizeTestConstants.CLIENT_ID).when(consentDataMock).getClientId();
+ doReturn(consentResourceMock).when(consentDataMock).getConsentResource();
+ doReturn(ConsentAuthorizeTestConstants.getAuthResource()).when(consentDataMock).getAuthResource();
+ doReturn(ConsentAuthorizeTestConstants.ACCOUNTS).when(consentResourceMock).getConsentType();
+ doReturn(true).when(consentPersistDataMock).getApproval();
+
+ JSONObject payload = (JSONObject) parser
+ .parse(ConsentAuthorizeTestConstants.PAYLOAD_WITH_NON_STRING_ACCOUNTID);
+ doReturn(payload).when(consentPersistDataMock).getPayload();
+
+ consentPersistStep.execute(consentPersistDataMock);
+ }
+
+ @Test(priority = 9, expectedExceptions = ConsentException.class)
+ public void testCOFConsentPersistWithoutCOFAccount() throws Exception {
+
+ doReturn(consentDataMock).when(consentPersistDataMock).getConsentData();
+ doReturn(ConsentAuthorizeTestConstants.CONSENT_ID).when(consentDataMock).getConsentId();
+ doReturn(ConsentAuthorizeTestConstants.USER_ID).when(consentDataMock).getUserId();
+ doReturn(ConsentAuthorizeTestConstants.CLIENT_ID).when(consentDataMock).getClientId();
+ doReturn(consentResourceMock).when(consentDataMock).getConsentResource();
+ doReturn(ConsentAuthorizeTestConstants.getAuthResource()).when(consentDataMock).getAuthResource();
+ doReturn(ConsentAuthorizeTestConstants.FUNDS_CONFIRMATIONS).when(consentResourceMock)
+ .getConsentType();
+ doReturn(true).when(consentPersistDataMock).getApproval();
+
+ JSONObject payload = (JSONObject) parser
+ .parse(ConsentAuthorizeTestConstants.COF_PERSIST_PAYLOAD_WITHOUT_COF_ACC);
+ doReturn(payload).when(consentPersistDataMock).getPayload();
+
+ consentPersistStep.execute(consentPersistDataMock);
+ }
+
+ @Test(priority = 10, expectedExceptions = ConsentException.class)
+ public void testCOFConsentPersistWithNonStringCOFAccount() throws Exception {
+
+ doReturn(consentDataMock).when(consentPersistDataMock).getConsentData();
+ doReturn(ConsentAuthorizeTestConstants.CONSENT_ID).when(consentDataMock).getConsentId();
+ doReturn(ConsentAuthorizeTestConstants.USER_ID).when(consentDataMock).getUserId();
+ doReturn(ConsentAuthorizeTestConstants.CLIENT_ID).when(consentDataMock).getClientId();
+ doReturn(consentResourceMock).when(consentDataMock).getConsentResource();
+ doReturn(ConsentAuthorizeTestConstants.getAuthResource()).when(consentDataMock).getAuthResource();
+ doReturn(ConsentAuthorizeTestConstants.FUNDS_CONFIRMATIONS).when(consentResourceMock)
+ .getConsentType();
+ doReturn(true).when(consentPersistDataMock).getApproval();
+
+ JSONObject payload = (JSONObject) parser
+ .parse(ConsentAuthorizeTestConstants.COF_PERSIST_PAYLOAD_WITH_NON_STRING_COF_ACC);
+ doReturn(payload).when(consentPersistDataMock).getPayload();
+
+ consentPersistStep.execute(consentPersistDataMock);
+ }
+
+ @Test(priority = 11, expectedExceptions = ConsentException.class)
+ public void testCOFPersistThrowingExceptionWhenConsentBinding() throws Exception {
+
+ doReturn(consentDataMock).when(consentPersistDataMock).getConsentData();
+ doReturn(ConsentAuthorizeTestConstants.CONSENT_ID).when(consentDataMock).getConsentId();
+ doReturn(ConsentAuthorizeTestConstants.USER_ID).when(consentDataMock).getUserId();
+ doReturn(ConsentAuthorizeTestConstants.CLIENT_ID).when(consentDataMock).getClientId();
+ doReturn(consentResourceMock).when(consentDataMock).getConsentResource();
+ doReturn(ConsentAuthorizeTestConstants.getAuthResource()).when(consentDataMock).getAuthResource();
+ doReturn(ConsentAuthorizeTestConstants.FUNDS_CONFIRMATIONS).when(consentResourceMock)
+ .getConsentType();
+ doReturn(false).when(consentPersistDataMock).getApproval();
+ JSONParser parser = new JSONParser(JSONParser.MODE_PERMISSIVE);
+ JSONObject payload = (JSONObject) parser
+ .parse(ConsentAuthorizeTestConstants.COF_PERSIST_PAYLOAD);
+ doReturn(payload).when(consentPersistDataMock).getPayload();
+
+ consentPersistStep.execute(consentPersistDataMock);
+ }
+
+}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authservlet/impl/AuthServletTest.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authservlet/impl/AuthServletTest.java
new file mode 100644
index 00000000..2be8ba4f
--- /dev/null
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authservlet/impl/AuthServletTest.java
@@ -0,0 +1,181 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.wso2.openbanking.accelerator.consent.extensions.authservlet.impl;
+
+import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentExtensionConstants;
+import com.wso2.openbanking.accelerator.consent.extensions.utils.AuthServletTestConstants;
+import org.json.JSONObject;
+import org.junit.Assert;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import java.util.Map;
+import java.util.ResourceBundle;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+/**
+ * Test class for OB Auth Servlet.
+ */
+@PowerMockIgnore("jdk.internal.reflect.*")
+public class AuthServletTest {
+
+ OBDefaultAuthServletImpl obAuthServlet;
+ @Mock
+ HttpServletRequest httpServletRequestMock;
+ @Mock
+ ResourceBundle resourceBundle;
+
+ @BeforeClass
+ public void initClass() {
+
+ MockitoAnnotations.initMocks(this);
+
+ obAuthServlet = new OBDefaultAuthServletImpl();
+ httpServletRequestMock = Mockito.mock(HttpServletRequest.class);
+ resourceBundle = Mockito.mock(ResourceBundle.class);
+ }
+
+ @Test
+ public void testUpdateRequestAttributeForAccounts() {
+
+ JSONObject accountObj = new JSONObject(AuthServletTestConstants.ACCOUNT_DATA);
+
+ Map requestAttributes = obAuthServlet.updateRequestAttribute(httpServletRequestMock,
+ accountObj, resourceBundle);
+
+ Assert.assertFalse(requestAttributes.isEmpty());
+ Assert.assertTrue(requestAttributes.containsKey(ConsentExtensionConstants.DATA_REQUESTED));
+ }
+
+ @Test
+ public void testUpdateRequestAttributeForCOF() {
+
+ JSONObject cofObj = new JSONObject(AuthServletTestConstants.COF_DATA);
+
+ Map requestAttributes = obAuthServlet.updateRequestAttribute(httpServletRequestMock,
+ cofObj, resourceBundle);
+
+ Assert.assertFalse(requestAttributes.isEmpty());
+ Assert.assertTrue(requestAttributes.containsKey(ConsentExtensionConstants.DATA_REQUESTED));
+ }
+
+ @Test
+ public void testUpdateRequestAttributeForPayments() {
+
+ JSONObject paymentObj = new JSONObject(AuthServletTestConstants.PAYMENT_DATA);
+ HttpSession session = Mockito.mock(HttpSession.class);
+ Mockito.doReturn(session).when(httpServletRequestMock).getSession();
+
+ Map requestAttributes = obAuthServlet.updateRequestAttribute(httpServletRequestMock,
+ paymentObj, resourceBundle);
+
+ Assert.assertFalse(requestAttributes.isEmpty());
+ Assert.assertTrue(requestAttributes.containsKey(ConsentExtensionConstants.DATA_REQUESTED));
+ }
+
+ @Test
+ public void testUpdateRequestAttributeForPaymentsWithoutDebtorAccInPayload() {
+
+ JSONObject paymentObj = new JSONObject(AuthServletTestConstants.PAYMENT_DATA_WITHOUT_DEBTOR_ACC);
+ HttpSession session = Mockito.mock(HttpSession.class);
+ Mockito.doReturn(session).when(httpServletRequestMock).getSession();
+
+ Map requestAttributes = obAuthServlet.updateRequestAttribute(httpServletRequestMock,
+ paymentObj, resourceBundle);
+
+ Assert.assertTrue(requestAttributes.isEmpty());
+ Assert.assertFalse(requestAttributes.containsKey(ConsentExtensionConstants.DATA_REQUESTED));
+ }
+
+ @Test
+ public void testUpdateRequestAttributeForVRP() {
+
+ JSONObject paymentObj = new JSONObject(AuthServletTestConstants.VRP_DATA);
+ HttpSession session = Mockito.mock(HttpSession.class);
+ Mockito.doReturn(session).when(httpServletRequestMock).getSession();
+
+ Map requestAttributes = obAuthServlet.updateRequestAttribute(httpServletRequestMock,
+ paymentObj, resourceBundle);
+
+ Assert.assertFalse(requestAttributes.isEmpty());
+ Assert.assertTrue(requestAttributes.containsKey(ConsentExtensionConstants.DATA_REQUESTED));
+ }
+
+ @Test
+ public void testUpdateRequestAttributeForVRPWithoutDebtorAcc() {
+
+ JSONObject paymentObj = new JSONObject(AuthServletTestConstants.VRP_DATA_WITHOUT_DEBTOR_ACC);
+ HttpSession session = Mockito.mock(HttpSession.class);
+ Mockito.doReturn(session).when(httpServletRequestMock).getSession();
+
+ Map requestAttributes = obAuthServlet.updateRequestAttribute(httpServletRequestMock,
+ paymentObj, resourceBundle);
+
+ Assert.assertFalse(requestAttributes.isEmpty());
+ Assert.assertTrue(requestAttributes.containsKey(ConsentExtensionConstants.DATA_REQUESTED));
+ }
+
+ @Test
+ public void testUpdateRequestAttributeForNonExistingType() {
+
+ JSONObject object = new JSONObject(AuthServletTestConstants.JSON_WITH_TYPE);
+
+ Map requestAttributes = obAuthServlet.updateRequestAttribute(httpServletRequestMock,
+ object, resourceBundle);
+
+ Assert.assertTrue(requestAttributes.isEmpty());
+ }
+
+ @Test
+ public void testUpdateConsentData() {
+
+ String param = "Test_parameter";
+ Mockito.doReturn(param).when(httpServletRequestMock).getParameter(Mockito.anyString());
+ HttpSession session = Mockito.mock(HttpSession.class);
+ Mockito.doReturn(session).when(httpServletRequestMock).getSession();
+
+ Map consentData = obAuthServlet.updateConsentData(httpServletRequestMock);
+ Assert.assertFalse(consentData.isEmpty());
+ Assert.assertTrue(consentData.containsKey(ConsentExtensionConstants.ACCOUNT_IDS));
+ Assert.assertTrue(consentData.containsKey(ConsentExtensionConstants.PAYMENT_ACCOUNT));
+ Assert.assertTrue(consentData.containsKey(ConsentExtensionConstants.COF_ACCOUNT));
+ }
+
+ @Test
+ public void testUpdateConsentMetaData() {
+
+ Map consentMetadata = obAuthServlet.updateConsentMetaData(httpServletRequestMock);
+
+ Assert.assertTrue(consentMetadata.isEmpty());
+ }
+
+ @Test
+ public void testUpdateSessionAttribute() {
+
+ Map sessionAttributes = obAuthServlet.updateSessionAttribute(httpServletRequestMock,
+ new JSONObject(), resourceBundle);
+
+ Assert.assertTrue(sessionAttributes.isEmpty());
+ }
+}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/utils/AuthServletTestConstants.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/utils/AuthServletTestConstants.java
new file mode 100644
index 00000000..a2d462af
--- /dev/null
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/utils/AuthServletTestConstants.java
@@ -0,0 +1,256 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.wso2.openbanking.accelerator.consent.extensions.utils;
+
+/**
+ * Constant class for OB Auth Servlet tests.
+ */
+public class AuthServletTestConstants {
+ public static final String ACCOUNT_DATA = "{" +
+ " \"consentData\": [" +
+ " {" +
+ " \"data\":[" +
+ " \"ReadAccountsBasic\"," +
+ " \"ReadAccountsDetail\"," +
+ " \"ReadBalances\"," +
+ " ]," +
+ " \"title\":\"Permissions\"" +
+ " }," +
+ " {" +
+ " \"data\":[\"2021-07-19T13:51:43.347+05:30\"]," +
+ " \"title\":\"Expiration Date Time\"" +
+ " }," +
+ " {" +
+ " \"data\":[\"2021-07-14T13:51:43.397+05:30\"]," +
+ " \"title\":\"Transaction From Date Time\"" +
+ " }," +
+ " {" +
+ " \"data\":[\"2021-07-17T13:51:43.397+05:30\"]," +
+ " \"title\":\"Transaction To Date Time\"}," +
+ " ]," +
+ " \"application\":\"9b5usDpbNtmxDcTzs7GzKp\"," +
+ " \"accounts\":[" +
+ " {" +
+ " \"accountId\":\"30080012343456\"," +
+ " \"account_id\":\"30080012343456\"," +
+ " \"authorizationMethod\":\"single\"," +
+ " \"accountName\":\"account_1\"," +
+ " \"nickName\":\"not-working\"," +
+ " \"display_name\":\"account_1\"" +
+ " }," +
+ " {" +
+ " \"accountId\":\"30080098763459\"," +
+ " \"account_id\":\"30080098763459\"," +
+ " \"authorizationMethod\":\"single\"," +
+ " \"accountName\":\"account_2\"," +
+ " \"display_name\":\"account_2\"" +
+ " }" +
+ " ]," +
+ " \"type\":\"accounts\"" +
+ "}";
+
+ public static final String COF_DATA = "{" +
+ " \"consentData\":[" +
+ " {" +
+ " \"data\":[\"2021-07-19T20:14:11.069+05:30\"]," +
+ " \"title\":\"Expiration Date Time\"" +
+ " }," +
+ " {" +
+ " \"data\":[" +
+ " \"Scheme Name : OB.SortCodeAccountNumber\"," +
+ " \"Identification : 1234\"," +
+ " \"Name : Account1\"," +
+ " \"Secondary Identification : Account1\"" +
+ " ]," +
+ " \"title\":\"Debtor Account\"" +
+ " }," +
+ " ]," +
+ " \"application\":\"9b5usDpbNtmxDcTzs7GzKp\"," +
+ " \"type\":\"fundsconfirmations\"," +
+ " \"debtor_account\":\"1234\"" +
+ "}";
+
+ public static final String PAYMENT_DATA = "{" +
+ " \"consentData\":[" +
+ " {" +
+ " \"data\":[\"Domestic Payments\"]," +
+ " \"title\":\"Payment Type\"" +
+ " }," +
+ " {" +
+ " \"data\":[\"ACME412\"]," +
+ " \"title\":\"Instruction Identification\"" +
+ " }," +
+ " {" +
+ " \"data\":[\"FRESCO.21302.GFX.20\"]," +
+ " \"title\":\"End to End Identification\"" +
+ " }," +
+ " {" +
+ " \"data\":[\"Amount : 30.80\",\"Currency : GBP\"]," +
+ " \"title\":\"Instructed Amount\"" +
+ " }," +
+ " {" +
+ " \"data\":[" +
+ " \"Scheme Name : OB.SortCodeAccountNumber\"," +
+ " \"Identification : 30080012343456\"," +
+ " \"Name : Andrea Smith\"," +
+ " \"Secondary Identification : 30080012343456\"" +
+ " ]," +
+ " \"title\":\"Debtor Account\"" +
+ " }," +
+ " {" +
+ " \"data\":[" +
+ " \"Scheme Name : OB.SortCodeAccountNumber\"," +
+ " \"Identification : 08080021325698\"," +
+ " \"Name : ACME Inc\"," +
+ " \"Secondary Identification : 0002\"" +
+ " ]," +
+ " \"title\":\"Creditor Account\"" +
+ " }," +
+ " ]," +
+ " \"application\":\"9b5usDpbNtmxDcTzs7GzKp\"," +
+ " \"type\":\"payments\"," +
+ " \"debtor_account\":\"30080012343456\"" +
+ "}";
+
+ public static final String PAYMENT_DATA_WITHOUT_DEBTOR_ACC = "{\n" +
+ " \"consentData\":[\n" +
+ " {\n" +
+ " \"data\":[\n" +
+ " \"Domestic Payments\"\n" +
+ " ],\n" +
+ " \"title\":\"Payment Type\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"data\":[\n" +
+ " \"ACME412\"\n" +
+ " ],\n" +
+ " \"title\":\"Instruction Identification\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"data\":[\n" +
+ " \"FRESCO.21302.GFX.20\"\n" +
+ " ],\n" +
+ " \"title\":\"End to End Identification\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"data\":[\n" +
+ " \"Amount : 30.80\",\n" +
+ " \"Currency : GBP\"\n" +
+ " ],\n" +
+ " \"title\":\"Instructed Amount\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"data\":[\n" +
+ " \"Scheme Name : OB.SortCodeAccountNumber\",\n" +
+ " \"Identification : 08080021325698\",\n" +
+ " \"Name : ACME Inc\"\n" +
+ " ],\n" +
+ " \"title\":\"Creditor Account\"\n" +
+ " },\n" +
+ " ]," +
+ " \"type\":\"Payments\"\n" +
+ "}";
+
+
+ public static final String VRP_DATA = "{" +
+ " \"consentData\":[" +
+ " {" +
+ " \"data\":[\"Domestic VRP\"]," +
+ " \"title\":\"Payment Type\"" +
+ " }," +
+ " {" +
+ " \"data\":[" +
+ " \"Scheme Name : OB.SortCodeAccountNumber\"," +
+ " \"Identification : 30080012343456\"," +
+ " \"Name : Andrea Smith\"," +
+ " \"Secondary Identification : 30080012343456\"" +
+ " ]," +
+ " \"title\":\"Debtor Account\"" +
+ " }," +
+ " {" +
+ " \"data\":[" +
+ " \"Scheme Name : OB.SortCodeAccountNumber\"," +
+ " \"Identification : 08080021325698\"," +
+ " \"Name : ACME Inc\"," +
+ " \"Secondary Identification : 0002\"" +
+ " ]," +
+ " \"title\":\"Creditor Account\"" +
+ " }," +
+ " {" +
+ " \"data\":[\"100\"]," +
+ " \"title\":\"Maximum amount per payment\"" +
+ " }," +
+ " {" +
+ " \"data\":[\"Consent\"]," +
+ " \"title\":\"Period Alignment\"" +
+ " }," +
+ " {" +
+ " \"data\":[\"200\"]," +
+ " \"title\":\"Maximum payment amount per Week\"" +
+ " }," +
+ " ]," +
+ " \"application\":\"9b5usDpbNtmxDcTzs7GzKp\"," +
+ " \"type\":\"vrp\"," +
+ " \"debtor_account\":\"30080012343456\"" +
+ "}";
+
+
+ public static final String VRP_DATA_WITHOUT_DEBTOR_ACC = "{" +
+ " \"consentData\":[" +
+ " {" +
+ " \"data\":[\"Domestic VRP\"]," +
+ " \"title\":\"Payment Type\"" +
+ " }," +
+ " {" +
+ " \"data\":[" +
+ " \"Scheme Name : OB.SortCodeAccountNumber\"," +
+ " \"Identification : 30080012343456\"," +
+ " \"Name : Andrea Smith\"," +
+ " \"Secondary Identification : 30080012343456\"" +
+ " ]," +
+ " \"title\":\"Debtor Account\"" +
+ " }," +
+ " {" +
+ " \"data\":[" +
+ " \"Scheme Name : OB.SortCodeAccountNumber\"," +
+ " \"Identification : 08080021325698\"," +
+ " \"Name : ACME Inc\"," +
+ " \"Secondary Identification : 0002\"" +
+ " ]," +
+ " \"title\":\"Creditor Account\"" +
+ " }," +
+ " {" +
+ " \"data\":[\"100\"]," +
+ " \"title\":\"Maximum amount per payment\"" +
+ " }," +
+ " {" +
+ " \"data\":[\"Consent\"]," +
+ " \"title\":\"Period Alignment\"" +
+ " }," +
+ " {" +
+ " \"data\":[\"200\"]," +
+ " \"title\":\"Maximum payment amount per Week\"" +
+ " }," +
+ " ]," +
+ " \"type\":\"vrp\"," +
+ "}";
+
+ public static final String JSON_WITH_TYPE = "{" +
+ " \"type\":\"test\"" +
+ "}";
+}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/ConsentAuthorizeTestConstants.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/utils/ConsentAuthorizeTestConstants.java
similarity index 79%
rename from open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/ConsentAuthorizeTestConstants.java
rename to open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/utils/ConsentAuthorizeTestConstants.java
index eeebf157..e0ac75d7 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/ConsentAuthorizeTestConstants.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/utils/ConsentAuthorizeTestConstants.java
@@ -16,13 +16,15 @@
* under the License.
*/
-package com.wso2.openbanking.accelerator.consent.extensions.authorize.vrp.retrieval.flow;
+package com.wso2.openbanking.accelerator.consent.extensions.utils;
+
+import com.wso2.openbanking.accelerator.consent.mgt.dao.models.AuthorizationResource;
import java.time.Instant;
import java.time.OffsetDateTime;
/**
- * Constant class for consent authorize tests.
+ * Constant class for consent authorize tests.
*/
public class ConsentAuthorizeTestConstants {
public static final String INVALID_REQUEST_OBJECT = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.aWF0.TIygRaBn7MUFR9Zzy3" +
@@ -63,8 +65,15 @@ public class ConsentAuthorizeTestConstants {
public static final String AWAITING_AUTH_STATUS = "awaitingAuthorisation";
-
public static final long CREATED_TIME = Instant.now().toEpochMilli();
+ public static final String ACCOUNTS = "accounts";
+ public static final String PAYMENTS = "payments";
+ public static final String FUNDS_CONFIRMATIONS = "fundsconfirmations";
+ public static final String VRP = "vrp";
+ public static final String PAYLOAD_WITH_NON_STRING_ACCOUNTID = "{\"accountIds\": [1234, 2345]}";
+ public static final String CONSENT_ID = "4ae1e012-eaa7-4994-a055-c6454f0aeeb4";
+ public static final String USER_ID = "admin@wso2.com";
+ public static final String CLIENT_ID = "9vblw2uUr7FOfQzI0_XGzM7IRxAa";
public static final String COF_RECEIPT = "{" +
" \"Data\": {" +
" \"DebtorAccount\": {" +
@@ -184,7 +193,6 @@ public class ConsentAuthorizeTestConstants {
" }\n" +
"}";
-
public static final String VRP_WITHOUT_DATA = "{\n" +
" \"\": {\n" +
" \"ReadRefundAccount\": \"Yes\",\n" +
@@ -243,10 +251,10 @@ public class ConsentAuthorizeTestConstants {
" \"Currency\": \"GBP\"\n" +
" },\n" +
" \"DebtorAccount\": {\n" +
- "\"SchemeName\": \"OB.SortCodeAccountNumber\",\n" +
- "\"Identification\": \"30080012343456\",\n" +
- "\"Name\": \"Andrea Smith\",\n" +
- "\"SecondaryIdentification\": \"30080012343456\"\n" +
+ "\"SchemeName\": \"OB.SortCodeAccountNumber\",\n" +
+ "\"Identification\": \"30080012343456\",\n" +
+ "\"Name\": \"Andrea Smith\",\n" +
+ "\"SecondaryIdentification\": \"30080012343456\"\n" +
" },\n" +
" \"CreditorAccount\": {\n" +
" \"SchemeName\": \"OB.SortCodeAccountNumber\",\n" +
@@ -319,4 +327,92 @@ public class ConsentAuthorizeTestConstants {
" \"PaymentContextCode\": \"TransferToThirdParty\"\n" +
" }\n" +
"}";
+
+ public static final String ACCOUNT_PERSIST_PAYLOAD_WITHOUT_ACCOUNT_ID = " " +
+ "{" +
+ " \"metadata\": {" +
+ " \"commonAuthId\":\"b37b9c9b-b5ce-4889-966e-9cb30f70cc78\"" +
+ " }," +
+ " \"cofAccount\":\"\"," +
+ " \"approval\":\"true\"," +
+ " \"accountIds\": \"\"," +
+ " \"isReauthorization\":\"false\"," +
+ " \"type\":\"accounts\"," +
+ " \"paymentAccount\":\"\"" +
+ "}";
+
+ public static final String COF_PERSIST_PAYLOAD = " " +
+ "{" +
+ " \"metadata\": {" +
+ " \"commonAuthId\":\"b37b9c9b-b5ce-4889-966e-9cb30f70cc78\"" +
+ " }," +
+ " \"approval\":\"true\"," +
+ " \"cofAccount\":\"1234\"," +
+ " \"accountIds\": \"\"," +
+ " \"isReauthorization\":\"false\"," +
+ " \"type\":\"accounts\"," +
+ " \"paymentAccount\":\"\"" +
+ "}";
+
+ public static final String COF_PERSIST_PAYLOAD_WITHOUT_COF_ACC = " " +
+ "{" +
+ " \"metadata\": {" +
+ " \"commonAuthId\":\"b37b9c9b-b5ce-4889-966e-9cb30f70cc78\"" +
+ " }," +
+ " \"approval\":\"true\"," +
+ " \"accountIds\": \"\"," +
+ " \"isReauthorization\":\"false\"," +
+ " \"type\":\"accounts\"," +
+ " \"paymentAccount\":\"\"" +
+ "}";
+
+ public static final String COF_PERSIST_PAYLOAD_WITH_NON_STRING_COF_ACC = " " +
+ "{" +
+ " \"metadata\": {" +
+ " \"commonAuthId\":\"b37b9c9b-b5ce-4889-966e-9cb30f70cc78\"" +
+ " }," +
+ " \"cofAccount\":1234," +
+ " \"approval\":\"true\"," +
+ " \"accountIds\": \"\"," +
+ " \"isReauthorization\":\"false\"," +
+ " \"type\":\"accounts\"," +
+ " \"paymentAccount\":\"\"" +
+ "}";
+
+
+ public static AuthorizationResource getAuthResource() {
+
+ AuthorizationResource authorizationResource = new AuthorizationResource();
+ authorizationResource.setAuthorizationID("1234");
+ authorizationResource.setConsentID(ConsentAuthorizeTestConstants.CONSENT_ID);
+ authorizationResource.setAuthorizationStatus("created");
+ authorizationResource.setAuthorizationType("authorization");
+
+ return authorizationResource;
+ }
+
+ public static final String PAYMENT_PERSIST_PAYLOAD =
+ " {" +
+ " \"metadata\":{" +
+ " \"commonAuthId\":\"4b3f5911-85b7-4489-86e8-3916f953f484\"" +
+ " }," +
+ " \"cofAccount\":\"\"," +
+ " \"approval\":\"true\"," +
+ " \"accountIds\":[\"\"]," +
+ " \"isReauthorization\":\"\"," +
+ " \"type\":\"payments\"," +
+ " \"paymentAccount\":\"30080012343456\"," +
+ " \"MultiAuthType\":\"Any\"," +
+ " \"MultiAuthExpiry\":\"1626755005019\"" +
+ " }";
+
+
+
+
+
+
+
+
+
+
}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/resources/testng.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/resources/testng.xml
index 1cb92604..c5168082 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/resources/testng.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/resources/testng.xml
@@ -28,6 +28,8 @@
+
+
From fa29ae703302ebdc6b481a49775b983428e0180f Mon Sep 17 00:00:00 2001
From: kalpana
Date: Tue, 12 Mar 2024 17:46:07 +0530
Subject: [PATCH 089/281] Fixing the changes after the code review
---
.../common/util/ErrorConstants.java | 7 +
.../impl/DefaultConsentRetrievalStep.java | 6 +-
.../authorize/utils/ConsentRetrievalUtil.java | 723 +++++++++---------
.../impl/OBDefaultAuthServletImpl.java | 5 -
.../authservlet/impl/util/Utils.java | 10 +-
.../common/ConsentExtensionConstants.java | 1 -
.../AcceleratorConsentExtensionFactory.java | 51 --
7 files changed, 389 insertions(+), 414 deletions(-)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java
index 2c2f4a25..7f5c8625 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java
@@ -290,7 +290,14 @@ public class ErrorConstants {
public static final String PATH_PERIOD_TYPE = "Data.ControlParameters.PeriodicLimits.PeriodType";
public static final String PATH_PERIOD_ALIGNMENT = "Data.ControlParameters.PeriodicLimits.PeriodAlignment";
+ // VRP Authorization flow
public static final String CONTROL_PARAMETERS_MISSING_ERROR = "Missing mandatory parameter the ControlParameters";
public static final String DATA_OBJECT_MISSING_ERROR = "Missing mandatory parameter the Data";
+ public static final String MAX_AMOUNT_NOT_JSON_OBJECT_ERROR = "Parameter Maximum Individual Amount is" +
+ "not of type JSONObject";
+ public static final String NOT_JSON_ARRAY_ERROR = "Parameter PeriodicLimits is not a JSON Array";
+ public static final String PERIOD_ALIGNMENT_NOT_STRING_ERROR = "Parameter Period Alignment is not a String";
+ public static final String PERIOD_TYPE_NOT_STRING_ERROR = "Parameter Period Type is not a String";
+ public static final String NOT_STRING_ERROR = "Parameter amount or currency is not a String";
}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/DefaultConsentRetrievalStep.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/DefaultConsentRetrievalStep.java
index 47950ff6..496db846 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/DefaultConsentRetrievalStep.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/DefaultConsentRetrievalStep.java
@@ -32,7 +32,6 @@
import com.wso2.openbanking.accelerator.consent.mgt.service.impl.ConsentCoreServiceImpl;
import net.minidev.json.JSONArray;
import net.minidev.json.JSONObject;
-import net.minidev.json.parser.ParseException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -104,7 +103,7 @@ public void execute(ConsentData consentData, JSONObject jsonObject) throws Conse
jsonObject.put(ConsentExtensionConstants.IS_ERROR,
((JSONObject) errorList.get(0)).getAsString("Message"));
return;
- } catch (ParseException | ConsentManagementException e) {
+ } catch (ConsentManagementException e) {
throw new ConsentException(ResponseStatus.INTERNAL_SERVER_ERROR,
"Exception occurred while getting consent data");
}
@@ -116,8 +115,7 @@ public void execute(ConsentData consentData, JSONObject jsonObject) throws Conse
* @return consent
* @throws ConsentException
*/
- public JSONArray getConsentDataSet(ConsentResource consentResource)
- throws ConsentException, ConsentManagementException, ParseException {
+ public JSONArray getConsentDataSet(ConsentResource consentResource) {
return ConsentRetrievalUtil.getConsentData(consentResource);
}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/utils/ConsentRetrievalUtil.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/utils/ConsentRetrievalUtil.java
index 43867e1f..db7547b3 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/utils/ConsentRetrievalUtil.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/utils/ConsentRetrievalUtil.java
@@ -58,7 +58,7 @@ public static String extractRequestObject(String spQueryParams) {
for (String param : spQueries) {
if (param.contains("request=")) {
requestObject = (param.substring("request=".length())).replaceAll(
- "\\r\\n|\\r|\\n|\\%20", "");
+ "\\r\\n|\\r|\\n|%20", "");
}
}
if (requestObject != null) {
@@ -184,7 +184,7 @@ public static void populateDebtorAccount(JSONObject initiation, JSONArray consen
JSONObject jsonElementDebtor = new JSONObject();
jsonElementDebtor.appendField(ConsentExtensionConstants.TITLE,
ConsentExtensionConstants.DEBTOR_ACC_TITLE);
- jsonElementDebtor.appendField(ConsentExtensionConstants.DATA_SIMPLE, debtorAccountArray);
+ jsonElementDebtor.appendField(StringUtils.lowerCase(ConsentExtensionConstants.DATA), debtorAccountArray);
consentDataJSON.add(jsonElementDebtor);
}
@@ -226,13 +226,13 @@ public static void populateCreditorAccount(JSONObject initiation, JSONArray cons
JSONObject jsonElementCreditor = new JSONObject();
jsonElementCreditor.appendField(ConsentExtensionConstants.TITLE,
ConsentExtensionConstants.CREDITOR_ACC_TITLE);
- jsonElementCreditor.appendField(ConsentExtensionConstants.DATA_SIMPLE, creditorAccountArray);
+ jsonElementCreditor.appendField(StringUtils.lowerCase(ConsentExtensionConstants.DATA),
+ creditorAccountArray);
consentDataJSON.add(jsonElementCreditor);
}
}
-
/**
* Method to append Dummy data for Account ID. Ideally should be separate step calling accounts service
*
@@ -258,263 +258,249 @@ public static JSONArray appendDummyAccountID() {
}
- /**
- * Method that invokes the relevant methods to populate data for each flow.
- *
- * @param consentResource Consent Resource parameter containing consent related information retrieved from database
- * @return ConsentDataJson array
- */
- public static JSONArray getConsentData(ConsentResource consentResource) {
-
- JSONArray consentDataJSON;
- try {
- consentDataJSON = new JSONArray();
- String receiptString = consentResource.getReceipt();
- Object receiptJSON = new JSONParser(JSONParser.MODE_PERMISSIVE).parse(receiptString);
-
- // Checking whether the request body is in JSON format
- if (!(receiptJSON instanceof JSONObject)) {
- log.error(ErrorConstants.NOT_JSON_OBJECT_ERROR);
- throw new ConsentException(ResponseStatus.INTERNAL_SERVER_ERROR, ErrorConstants.NOT_JSON_OBJECT_ERROR);
- }
-
- // Checking whether the consent status is valid
- if (!consentResource.getCurrentStatus().equals(ConsentExtensionConstants.AWAITING_AUTH_STATUS)) {
- log.error(ErrorConstants.STATE_INVALID_ERROR);
- // Currently throwing an error as a 400 response.
- // Developers have the option of appending a field IS_ERROR to the jsonObject
- // and showing it to the user in the webapp. If so, the IS_ERROR has to be checked in any later steps.
- throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.STATE_INVALID_ERROR);
- }
-
- JSONObject receipt = (JSONObject) receiptJSON;
-
- // Checks if 'data' object is present in the receipt
- if (receipt.containsKey(ConsentExtensionConstants.DATA)) {
- JSONObject data = (JSONObject) receipt.get(ConsentExtensionConstants.DATA);
-
- String type = consentResource.getConsentType();
- switch (type) {
- case ConsentExtensionConstants.ACCOUNTS:
- consentDataJSON = populateAccountData(data, consentDataJSON);
- break;
- case ConsentExtensionConstants.PAYMENTS:
- consentDataJSON = populatePaymentData(data, consentDataJSON);
- break;
- case ConsentExtensionConstants.FUNDSCONFIRMATIONS:
- consentDataJSON = populateCofData(data, consentDataJSON);
- break;
- case ConsentExtensionConstants.VRP:
- // Check if 'controlParameters' object is present in the 'data'
- if (data.containsKey(ConsentExtensionConstants.CONTROL_PARAMETERS)) {
- JSONObject controlParameters = (JSONObject) data.
- get(ConsentExtensionConstants.CONTROL_PARAMETERS);
-
- populateVRPData(controlParameters, consentDataJSON);
- } else {
- log.error(ErrorConstants.CONTROL_PARAMETERS_MISSING_ERROR);
- throw new ConsentException(ResponseStatus.BAD_REQUEST,
- ErrorConstants.CONTROL_PARAMETERS_MISSING_ERROR);
- }
- break;
- default:
- break;
+ /**
+ * Method that consists the implementation for the validation of payload and the consent,
+ * this method also invokes the relevant methods to populate data for each flow.
+ *
+ * @param consentResource Consent Resource parameter containing consent related information retrieved
+ * from database
+ * @return ConsentDataJson array
+ */
+ public static JSONArray getConsentData(ConsentResource consentResource) throws ConsentException {
+
+ JSONArray consentDataJSON = new JSONArray();
+ try {
+
+ String receiptString = consentResource.getReceipt();
+ Object receiptJSON = new JSONParser(JSONParser.MODE_PERMISSIVE).parse(receiptString);
+
+ // Checking whether the request body is in JSON format
+ if (!(receiptJSON instanceof JSONObject)) {
+ log.error(ErrorConstants.NOT_JSON_OBJECT_ERROR);
+ throw new ConsentException(ResponseStatus.INTERNAL_SERVER_ERROR,
+ ErrorConstants.NOT_JSON_OBJECT_ERROR);
}
- } else {
- log.error(ErrorConstants.DATA_OBJECT_MISSING_ERROR);
- throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.DATA_OBJECT_MISSING_ERROR);
- }
- } catch (ParseException e) {
- log.error(ErrorConstants.CONSENT_RETRIEVAL_ERROR);
- throw new ConsentException(ResponseStatus.INTERNAL_SERVER_ERROR, ErrorConstants.CONSENT_RETRIEVAL_ERROR);
- }
-
- return consentDataJSON;
- }
+ if (!consentResource.getCurrentStatus().equals(ConsentExtensionConstants.AWAITING_AUTH_STATUS)) {
+ log.error(ErrorConstants.STATE_INVALID_ERROR);
+ // Currently throwing an error as a 400 response.
+ // Developers have the option of appending a field IS_ERROR to the jsonObject
+ // and showing it to the user in the webapp.If so,the IS_ERROR has to be checked in any later steps.
+ throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.STATE_INVALID_ERROR);
+ }
+ JSONObject receipt = (JSONObject) receiptJSON;
+
+ // Checks if 'data' object is present in the receipt
+ if (receipt.containsKey(ConsentExtensionConstants.DATA)) {
+ JSONObject data = (JSONObject) receipt.get(ConsentExtensionConstants.DATA);
+
+ String type = consentResource.getConsentType();
+ switch (type) {
+ case ConsentExtensionConstants.ACCOUNTS:
+ populateAccountData(data, consentDataJSON);
+ break;
+ case ConsentExtensionConstants.PAYMENTS:
+ populatePaymentData(data, consentDataJSON);
+ break;
+ case ConsentExtensionConstants.FUNDSCONFIRMATIONS:
+ populateCofData(data, consentDataJSON);
+ break;
+ case ConsentExtensionConstants.VRP:
+ populateVRPData(data, consentDataJSON);
+ break;
+ default:
+ break;
+ }
+ } else {
+ log.error(ErrorConstants.DATA_OBJECT_MISSING_ERROR);
+ throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.DATA_OBJECT_MISSING_ERROR);
+ }
- /**
- * Populate Domestic and international Payment Details.
- *
- * @param data data request from the request
- * @param consentDataJSON Consent information
- */
- private static JSONArray populatePaymentData(JSONObject data, JSONArray consentDataJSON) {
+ } catch (ParseException e) {
+ log.error(ErrorConstants.CONSENT_RETRIEVAL_ERROR, e);
+ throw new ConsentException(ResponseStatus.INTERNAL_SERVER_ERROR,
+ ErrorConstants.CONSENT_RETRIEVAL_ERROR);
+ }
- if (consentDataJSON == null) {
- // Initialize consentDataJSON if it's null
- consentDataJSON = new JSONArray();
+ return consentDataJSON;
}
- JSONArray paymentTypeArray = new JSONArray();
- JSONObject jsonElementPaymentType = new JSONObject();
- if (data.containsKey(ConsentExtensionConstants.INITIATION)) {
- JSONObject initiation = (JSONObject) data.get(ConsentExtensionConstants.INITIATION);
+ /**
+ * Populate Domestic and international Payment Details.
+ *
+ * @param data data request from the request
+ * @param consentDataJSON Consent information
+ */
+ private static void populatePaymentData(JSONObject data, JSONArray consentDataJSON) {
+
+ JSONArray paymentTypeArray = new JSONArray();
+ JSONObject jsonElementPaymentType = new JSONObject();
+
+ if (data.containsKey(ConsentExtensionConstants.INITIATION)) {
+ JSONObject initiation = (JSONObject) data.get(ConsentExtensionConstants.INITIATION);
+
+ if (initiation.containsKey(ConsentExtensionConstants.CURRENCY_OF_TRANSFER)) {
+ //For International Payments
+ //Adding Payment Type
+ paymentTypeArray.add(ConsentExtensionConstants.INTERNATIONAL_PAYMENTS);
+
+ jsonElementPaymentType.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.PAYMENT_TYPE_TITLE);
+ jsonElementPaymentType.appendField(StringUtils.lowerCase(ConsentExtensionConstants.DATA),
+ paymentTypeArray);
+ consentDataJSON.add(jsonElementPaymentType);
+
+ //Adding Currency Of Transfer
+ JSONArray currencyTransferArray = new JSONArray();
+ currencyTransferArray.add(initiation.getAsString(ConsentExtensionConstants.CURRENCY_OF_TRANSFER));
+
+ JSONObject jsonElementCurTransfer = new JSONObject();
+ jsonElementCurTransfer.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.CURRENCY_OF_TRANSFER_TITLE);
+ jsonElementCurTransfer.appendField(StringUtils.lowerCase(ConsentExtensionConstants.DATA),
+ currencyTransferArray);
+ consentDataJSON.add(jsonElementCurTransfer);
+ } else {
+ //Adding Payment Type
+ paymentTypeArray.add(ConsentExtensionConstants.DOMESTIC_PAYMENTS);
+
+ jsonElementPaymentType.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.PAYMENT_TYPE_TITLE);
+ jsonElementPaymentType.appendField(StringUtils.lowerCase(ConsentExtensionConstants.DATA),
+ paymentTypeArray);
+ consentDataJSON.add(jsonElementPaymentType);
+ }
- if (initiation.containsKey(ConsentExtensionConstants.CURRENCY_OF_TRANSFER)) {
- //For International Payments
- //Adding Payment Type
- paymentTypeArray.add(ConsentExtensionConstants.INTERNATIONAL_PAYMENTS);
+ //Adding InstructionIdentification
+ JSONArray identificationArray = new JSONArray();
+ identificationArray.add(initiation.getAsString(ConsentExtensionConstants.INSTRUCTION_IDENTIFICATION));
+
+ JSONObject jsonElementIdentification = new JSONObject();
+ jsonElementIdentification.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.INSTRUCTION_IDENTIFICATION_TITLE);
+ jsonElementIdentification.appendField(StringUtils.lowerCase(ConsentExtensionConstants.DATA),
+ identificationArray);
+ consentDataJSON.add(jsonElementIdentification);
+
+ //Adding EndToEndIdentification
+ JSONArray endToEndIdentificationArray = new JSONArray();
+ endToEndIdentificationArray
+ .add(initiation.getAsString(ConsentExtensionConstants.END_TO_END_IDENTIFICATION));
+
+ JSONObject jsonElementEndToEndIdentification = new JSONObject();
+ jsonElementEndToEndIdentification.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.END_TO_END_IDENTIFICATION_TITLE);
+ jsonElementEndToEndIdentification.appendField(StringUtils.lowerCase(ConsentExtensionConstants.DATA),
+ endToEndIdentificationArray);
+ consentDataJSON.add(jsonElementEndToEndIdentification);
+
+ //Adding InstructedAmount
+ JSONObject instructedAmount = (JSONObject) initiation.get(ConsentExtensionConstants.INSTRUCTED_AMOUNT);
+ JSONArray instructedAmountArray = new JSONArray();
+
+
+ if (instructedAmount.getAsString(ConsentExtensionConstants.AMOUNT_TITLE) != null) {
+ instructedAmountArray.add(ConsentExtensionConstants.AMOUNT_TITLE + " : " +
+ instructedAmount.getAsString(ConsentExtensionConstants.AMOUNT));
+ }
- jsonElementPaymentType.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.PAYMENT_TYPE_TITLE);
- jsonElementPaymentType.appendField(ConsentExtensionConstants.DATA_SIMPLE, paymentTypeArray);
- consentDataJSON.add(jsonElementPaymentType);
+ if (instructedAmount.getAsString(ConsentExtensionConstants.CURRENCY) != null) {
+ instructedAmountArray.add(ConsentExtensionConstants.CURRENCY_TITLE + " : " +
+ instructedAmount.getAsString(ConsentExtensionConstants.CURRENCY));
+ }
- //Adding Currency Of Transfer
- JSONArray currencyTransferArray = new JSONArray();
- currencyTransferArray.add(initiation.getAsString(ConsentExtensionConstants.CURRENCY_OF_TRANSFER));
+ JSONObject jsonElementInstructedAmount = new JSONObject();
+ jsonElementInstructedAmount.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.INSTRUCTED_AMOUNT_TITLE);
+ jsonElementInstructedAmount.appendField(StringUtils.lowerCase(ConsentExtensionConstants.DATA),
+ instructedAmountArray);
+ consentDataJSON.add(jsonElementInstructedAmount);
- JSONObject jsonElementCurTransfer = new JSONObject();
- jsonElementCurTransfer.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.CURRENCY_OF_TRANSFER_TITLE);
- jsonElementCurTransfer.appendField(ConsentExtensionConstants.DATA_SIMPLE, currencyTransferArray);
- consentDataJSON.add(jsonElementCurTransfer);
- } else {
- //Adding Payment Type
- paymentTypeArray.add(ConsentExtensionConstants.DOMESTIC_PAYMENTS);
+ // Adding Debtor Account
+ populateDebtorAccount(initiation, consentDataJSON);
+ // Adding Creditor Account
+ populateCreditorAccount(initiation, consentDataJSON);
- jsonElementPaymentType.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.PAYMENT_TYPE_TITLE);
- jsonElementPaymentType.appendField(ConsentExtensionConstants.DATA_SIMPLE, paymentTypeArray);
- consentDataJSON.add(jsonElementPaymentType);
}
- //Adding InstructionIdentification
- JSONArray identificationArray = new JSONArray();
- identificationArray.add(initiation.getAsString(ConsentExtensionConstants.INSTRUCTION_IDENTIFICATION));
-
- JSONObject jsonElementIdentification = new JSONObject();
- jsonElementIdentification.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.INSTRUCTION_IDENTIFICATION_TITLE);
- jsonElementIdentification.appendField(ConsentExtensionConstants.DATA_SIMPLE, identificationArray);
- consentDataJSON.add(jsonElementIdentification);
-
- //Adding EndToEndIdentification
- JSONArray endToEndIdentificationArray = new JSONArray();
- endToEndIdentificationArray
- .add(initiation.getAsString(ConsentExtensionConstants.END_TO_END_IDENTIFICATION));
-
- JSONObject jsonElementEndToEndIdentification = new JSONObject();
- jsonElementEndToEndIdentification.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.END_TO_END_IDENTIFICATION_TITLE);
- jsonElementEndToEndIdentification.appendField(ConsentExtensionConstants.DATA_SIMPLE,
- endToEndIdentificationArray);
- consentDataJSON.add(jsonElementEndToEndIdentification);
+ }
- //Adding InstructedAmount
- JSONObject instructedAmount = (JSONObject) initiation.get(ConsentExtensionConstants.INSTRUCTED_AMOUNT);
- JSONArray instructedAmountArray = new JSONArray();
+ /**
+ * Populate account Details.
+ *
+ * @param data data request from the request
+ * @param consentDataJSON Consent information
+ */
+ private static void populateAccountData(JSONObject data, JSONArray consentDataJSON) {
+
+ //Adding Permissions
+ JSONArray permissions = (JSONArray) data.get(ConsentExtensionConstants.PERMISSIONS);
+ if (permissions != null) {
+ JSONObject jsonElementPermissions = new JSONObject();
+ jsonElementPermissions.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.PERMISSIONS);
+ jsonElementPermissions.appendField(StringUtils.lowerCase(ConsentExtensionConstants.DATA),
+ permissions);
+ consentDataJSON.add(jsonElementPermissions);
+ }
+ //Adding Expiration Date Time
+ String expirationDate = data.getAsString(ConsentExtensionConstants.EXPIRATION_DATE);
+ if (expirationDate != null) {
+ if (!ConsentRetrievalUtil.validateExpiryDateTime(expirationDate)) {
+ log.error(ErrorConstants.CONSENT_EXPIRED);
+ throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.CONSENT_EXPIRED);
+ }
+ JSONArray expiryArray = new JSONArray();
+ expiryArray.add(expirationDate);
- if (instructedAmount.getAsString(ConsentExtensionConstants.AMOUNT_TITLE) != null) {
- instructedAmountArray.add(ConsentExtensionConstants.AMOUNT_TITLE + " : " +
- instructedAmount.getAsString(ConsentExtensionConstants.AMOUNT));
+ JSONObject jsonElementExpiry = new JSONObject();
+ jsonElementExpiry.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.EXPIRATION_DATE_TITLE);
+ jsonElementExpiry.appendField(StringUtils.lowerCase(ConsentExtensionConstants.DATA),
+ expiryArray);
+ consentDataJSON.add(jsonElementExpiry);
}
- if (instructedAmount.getAsString(ConsentExtensionConstants.CURRENCY) != null) {
- instructedAmountArray.add(ConsentExtensionConstants.CURRENCY_TITLE + " : " +
- instructedAmount.getAsString(ConsentExtensionConstants.CURRENCY));
+ //Adding Transaction From Date Time
+ String fromDateTime = data.getAsString(ConsentExtensionConstants.TRANSACTION_FROM_DATE);
+ if (fromDateTime != null) {
+ JSONArray fromDateTimeArray = new JSONArray();
+ fromDateTimeArray.add(fromDateTime);
+
+ JSONObject jsonElementFromDateTime = new JSONObject();
+ jsonElementFromDateTime.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.TRANSACTION_FROM_DATE_TITLE);
+ jsonElementFromDateTime.appendField(StringUtils.lowerCase(ConsentExtensionConstants.DATA),
+ fromDateTimeArray);
+ consentDataJSON.add(jsonElementFromDateTime);
}
- JSONObject jsonElementInstructedAmount = new JSONObject();
- jsonElementInstructedAmount.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.INSTRUCTED_AMOUNT_TITLE);
- jsonElementInstructedAmount.appendField(ConsentExtensionConstants.DATA_SIMPLE, instructedAmountArray);
- consentDataJSON.add(jsonElementInstructedAmount);
-
- // Adding Debtor Account
- populateDebtorAccount(initiation, consentDataJSON);
- // Adding Creditor Account
- populateCreditorAccount(initiation, consentDataJSON);
-
- }
- return consentDataJSON;
-
- }
-
- /**
- * Populate account Details.
- *
- * @param data data request from the request
- * @param consentDataJSON Consent information
- */
- private static JSONArray populateAccountData(JSONObject data, JSONArray consentDataJSON) {
-
- if (consentDataJSON == null) {
- consentDataJSON = new JSONArray();
- }
-
- //Adding Permissions
- JSONArray permissions = (JSONArray) data.get(ConsentExtensionConstants.PERMISSIONS);
- if (permissions != null) {
- JSONObject jsonElementPermissions = new JSONObject();
- jsonElementPermissions.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.PERMISSIONS);
- jsonElementPermissions.appendField(ConsentExtensionConstants.DATA_SIMPLE, permissions);
- consentDataJSON.add(jsonElementPermissions);
- }
-
- //Adding Expiration Date Time
- String expirationDate = data.getAsString(ConsentExtensionConstants.EXPIRATION_DATE);
- if (expirationDate != null) {
- if (!ConsentRetrievalUtil.validateExpiryDateTime(expirationDate)) {
- log.error(ErrorConstants.CONSENT_EXPIRED);
- throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.CONSENT_EXPIRED);
+ //Adding Transaction To Date Time
+ String toDateTime = data.getAsString(ConsentExtensionConstants.TRANSACTION_TO_DATE);
+ if (toDateTime != null) {
+ JSONArray toDateTimeArray = new JSONArray();
+ toDateTimeArray.add(toDateTime);
+
+ JSONObject jsonElementToDateTime = new JSONObject();
+ jsonElementToDateTime.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.TRANSACTION_TO_DATE_TITLE);
+ jsonElementToDateTime.appendField(StringUtils.lowerCase(ConsentExtensionConstants.DATA),
+ toDateTimeArray);
+ consentDataJSON.add(jsonElementToDateTime);
}
- JSONArray expiryArray = new JSONArray();
- expiryArray.add(expirationDate);
-
- JSONObject jsonElementExpiry = new JSONObject();
- jsonElementExpiry.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.EXPIRATION_DATE_TITLE);
- jsonElementExpiry.appendField(ConsentExtensionConstants.DATA_SIMPLE, expiryArray);
- consentDataJSON.add(jsonElementExpiry);
- }
- //Adding Transaction From Date Time
- String fromDateTime = data.getAsString(ConsentExtensionConstants.TRANSACTION_FROM_DATE);
- if (fromDateTime != null) {
- JSONArray fromDateTimeArray = new JSONArray();
- fromDateTimeArray.add(fromDateTime);
-
- JSONObject jsonElementFromDateTime = new JSONObject();
- jsonElementFromDateTime.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.TRANSACTION_FROM_DATE_TITLE);
- jsonElementFromDateTime.appendField(ConsentExtensionConstants.DATA_SIMPLE, fromDateTimeArray);
- consentDataJSON.add(jsonElementFromDateTime);
}
- //Adding Transaction To Date Time
- String toDateTime = data.getAsString(ConsentExtensionConstants.TRANSACTION_TO_DATE);
- if (toDateTime != null) {
- JSONArray toDateTimeArray = new JSONArray();
- toDateTimeArray.add(toDateTime);
-
- JSONObject jsonElementToDateTime = new JSONObject();
- jsonElementToDateTime.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.TRANSACTION_TO_DATE_TITLE);
- jsonElementToDateTime.appendField(ConsentExtensionConstants.DATA_SIMPLE, toDateTimeArray);
- consentDataJSON.add(jsonElementToDateTime);
- }
-
- return consentDataJSON;
-
- }
-
- /**
- * Populate funds confirmation Details.
- *
- * @param initiation data from the request
- * @param consentDataJSON Consent information
- */
- private static JSONArray populateCofData(JSONObject initiation, JSONArray consentDataJSON) {
-
- if (consentDataJSON == null) {
- consentDataJSON = new JSONArray();
- }
+ /**
+ * Populate funds confirmation Details.
+ *
+ * @param initiation data from the request
+ * @param consentDataJSON Consent information
+ */
+ private static void populateCofData(JSONObject initiation, JSONArray consentDataJSON) {
//Adding Expiration Date Time
if (initiation.getAsString(ConsentExtensionConstants.EXPIRATION_DATE) != null) {
@@ -532,7 +518,7 @@ private static JSONArray populateCofData(JSONObject initiation, JSONArray consen
JSONObject jsonElementExpiry = new JSONObject();
jsonElementExpiry.appendField(ConsentExtensionConstants.TITLE,
ConsentExtensionConstants.EXPIRATION_DATE_TITLE);
- jsonElementExpiry.appendField(ConsentExtensionConstants.DATA_SIMPLE, expiryArray);
+ jsonElementExpiry.appendField(StringUtils.lowerCase(ConsentExtensionConstants.DATA), expiryArray);
consentDataJSON.add(jsonElementExpiry);
} else {
JSONArray expiryArray = new JSONArray();
@@ -541,143 +527,184 @@ private static JSONArray populateCofData(JSONObject initiation, JSONArray consen
JSONObject jsonElementExpiry = new JSONObject();
jsonElementExpiry.appendField(ConsentExtensionConstants.TITLE,
ConsentExtensionConstants.EXPIRATION_DATE_TITLE);
- jsonElementExpiry.appendField(ConsentExtensionConstants.DATA_SIMPLE, expiryArray);
+ jsonElementExpiry.appendField(StringUtils.lowerCase(ConsentExtensionConstants.DATA), expiryArray);
consentDataJSON.add(jsonElementExpiry);
-
}
- if (initiation.get(ConsentExtensionConstants.DEBTOR_ACC) != null) {
- //Adding Debtor Account
- populateDebtorAccount(initiation, consentDataJSON);
+ if (initiation.get(ConsentExtensionConstants.DEBTOR_ACC) != null) {
+ //Adding Debtor Account
+ populateDebtorAccount(initiation, consentDataJSON);
+ }
}
- return consentDataJSON;
- }
+ /**
+ * Populate VRP Details.
+ *
+ * @param data Control Parameters from the request
+ * @param consentDataJSON Consent information object
+ */
+ private static void populateVRPData(JSONObject data, JSONArray consentDataJSON) {
- /**
- * Populate VRP Details.
- *
- * @param controlParameters Control Parameters from the request
- * @param consentDataJSON Consent information object
- */
- private static JSONArray populateVRPData(JSONObject controlParameters, JSONArray consentDataJSON) {
+ if (data.containsKey(ConsentExtensionConstants.CONTROL_PARAMETERS)) {
- if (consentDataJSON == null) {
- consentDataJSON = new JSONArray();
- }
+ JSONObject controlParameters = (JSONObject) data.
+ get(ConsentExtensionConstants.CONTROL_PARAMETERS);
- JSONArray paymentTypeArray = new JSONArray();
- JSONObject jsonElementPaymentType = new JSONObject();
-
- //Adding Payment Type
- paymentTypeArray.add(ConsentExtensionConstants.DOMESTIC_VRP);
- jsonElementPaymentType.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.PAYMENT_TYPE_TITLE);
- jsonElementPaymentType.appendField(ConsentExtensionConstants.DATA_SIMPLE, paymentTypeArray);
- consentDataJSON.add(jsonElementPaymentType);
-
- String expirationDate = controlParameters.getAsString(ConsentExtensionConstants.VALID_FROM_DATE_TIME);
- if (expirationDate != null) {
- // Constructing jsonElementValidToDataTime
- JSONObject jsonElementValidToDateTime = new JSONObject();
- jsonElementValidToDateTime.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.CONTROL_PARAMETER_VALID_TO_DATE_TITLE);
- JSONArray dateControlParameterArray = new JSONArray();
- dateControlParameterArray.add((controlParameters).
- get(ConsentExtensionConstants.VALID_TO_DATE_TIME));
- jsonElementValidToDateTime.appendField(ConsentExtensionConstants.DATA_SIMPLE, dateControlParameterArray);
-
- consentDataJSON.add(jsonElementValidToDateTime);
- }
+ //Adding Payment Type
+ JSONArray paymentTypeArray = new JSONArray();
+ JSONObject jsonElementPaymentType = new JSONObject();
+ paymentTypeArray.add(ConsentExtensionConstants.DOMESTIC_VRP);
+ jsonElementPaymentType.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.PAYMENT_TYPE_TITLE);
+ jsonElementPaymentType.appendField(StringUtils.lowerCase(ConsentExtensionConstants.DATA),
+ paymentTypeArray);
+ consentDataJSON.add(jsonElementPaymentType);
- String expirationDates = controlParameters.getAsString(ConsentExtensionConstants.VALID_TO_DATE_TIME);
- if (expirationDates != null) {
- // Constructing jsonElementValidFromDataTime
- JSONObject jsonElementValidFromDateTime = new JSONObject();
- jsonElementValidFromDateTime.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.CONTROL_PARAMETER_VALID_FROM_DATE_TITLE);
- JSONArray dateTimeControlParameterArray = new JSONArray();
- dateTimeControlParameterArray.add((controlParameters).
- get(ConsentExtensionConstants.VALID_FROM_DATE_TIME));
- jsonElementValidFromDateTime.appendField(ConsentExtensionConstants.DATA_SIMPLE,
- dateTimeControlParameterArray);
- consentDataJSON.add(jsonElementValidFromDateTime);
- }
+ String validToDateTime = controlParameters.getAsString(ConsentExtensionConstants.VALID_TO_DATE_TIME);
+ if (validToDateTime != null) {
+ // Constructing jsonElementValidToDataTime
+ JSONObject jsonElementValidToDateTime = new JSONObject();
+ jsonElementValidToDateTime.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.CONTROL_PARAMETER_VALID_TO_DATE_TITLE);
+ JSONArray dateControlParameterArray = new JSONArray();
+ dateControlParameterArray.add((controlParameters).
+ get(ConsentExtensionConstants.VALID_TO_DATE_TIME));
+ jsonElementValidToDateTime.appendField(StringUtils.lowerCase(ConsentExtensionConstants.DATA),
+ dateControlParameterArray);
+
+ consentDataJSON.add(jsonElementValidToDateTime);
+ }
- String maxAmount = controlParameters.getAsString(ConsentExtensionConstants.MAXIMUM_INDIVIDUAL_AMOUNT);
- if (maxAmount != null) {
- // Constructing jsonElementControlParameter
- JSONObject jsonElementControlParameter = new JSONObject();
- jsonElementControlParameter.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.CONTROL_PARAMETER_MAX_INDIVIDUAL_AMOUNT_TITLE);
- JSONArray controlParameterArray = new JSONArray();
+ String validFromDateTime = controlParameters.getAsString
+ (ConsentExtensionConstants.VALID_FROM_DATE_TIME);
+ if (validFromDateTime != null) {
+ // Constructing jsonElementValidFromDataTime
+ JSONObject jsonElementValidFromDateTime = new JSONObject();
+ jsonElementValidFromDateTime.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.CONTROL_PARAMETER_VALID_FROM_DATE_TITLE);
+ JSONArray dateTimeControlParameterArray = new JSONArray();
+ dateTimeControlParameterArray.add((controlParameters).
+ get(ConsentExtensionConstants.VALID_FROM_DATE_TIME));
+ jsonElementValidFromDateTime.appendField(StringUtils.lowerCase(ConsentExtensionConstants.DATA),
+ dateTimeControlParameterArray);
+ consentDataJSON.add(jsonElementValidFromDateTime);
+ }
+ Object maxAmount = controlParameters.get(ConsentExtensionConstants.MAXIMUM_INDIVIDUAL_AMOUNT);
- JSONObject maximumIndividualAmount = ((JSONObject) controlParameters.
- get(ConsentExtensionConstants.MAXIMUM_INDIVIDUAL_AMOUNT));
+ if (maxAmount instanceof JSONObject) {
+ JSONObject jsonElementControlParameter = new JSONObject();
+ jsonElementControlParameter.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.CONTROL_PARAMETER_MAX_INDIVIDUAL_AMOUNT_TITLE);
+ JSONArray controlParameterArray = new JSONArray();
- String formattedAmount = String.format("%s %s",
- (maximumIndividualAmount.get(ConsentExtensionConstants.CURRENCY)),
- (maximumIndividualAmount.get(ConsentExtensionConstants.AMOUNT)));
- controlParameterArray.add(formattedAmount);
- jsonElementControlParameter.appendField(ConsentExtensionConstants.DATA_SIMPLE, controlParameterArray);
+ JSONObject maximumIndividualAmount = (JSONObject) maxAmount;
- consentDataJSON.add(jsonElementControlParameter);
- }
+ String formattedAmount = String.format("%s %s",
+ maximumIndividualAmount.getAsString(ConsentExtensionConstants.CURRENCY),
+ maximumIndividualAmount.getAsString(ConsentExtensionConstants.AMOUNT));
+ controlParameterArray.add(formattedAmount);
+ jsonElementControlParameter.appendField(StringUtils.lowerCase(ConsentExtensionConstants.DATA),
+ controlParameterArray);
- // Constructing jsonElementPeriodAlignment
- JSONObject jsonElementPeriodAlignment = new JSONObject();
- jsonElementPeriodAlignment.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.CONTROL_PARAMETER_PERIOD_ALIGNMENT_TITLE);
- String periodAlignment = (String) ((JSONObject) ((JSONArray) controlParameters
- .get(ConsentExtensionConstants.PERIODIC_LIMITS)).get(0))
- .get(ConsentExtensionConstants.PERIOD_ALIGNMENT);
-
- if (periodAlignment != null) {
- JSONArray periodAlignmentArray = new JSONArray();
- periodAlignmentArray.add(periodAlignment);
- jsonElementPeriodAlignment.appendField(ConsentExtensionConstants.DATA_SIMPLE, periodAlignmentArray);
- consentDataJSON.add(jsonElementPeriodAlignment);
- }
+ consentDataJSON.add(jsonElementControlParameter);
+ } else {
+ log.error(ErrorConstants.MAX_AMOUNT_NOT_JSON_OBJECT_ERROR);
+ throw new ConsentException(ResponseStatus.BAD_REQUEST,
+ ErrorConstants.MAX_AMOUNT_NOT_JSON_OBJECT_ERROR);
+ }
- // Constructing jsonElementPeriodType
- JSONObject jsonElementPeriodType = new JSONObject();
- jsonElementPeriodType.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.CONTROL_PARAMETER_PERIOD_TYPE_TITLE);
- String periodType = (String) ((JSONObject) ((JSONArray) controlParameters
- .get(ConsentExtensionConstants.PERIODIC_LIMITS)).get(0)).get(ConsentExtensionConstants.PERIOD_TYPE);
-
- if (periodType != null) {
- JSONArray periodTypeArray = new JSONArray();
- periodTypeArray.add(periodType);
- jsonElementPeriodType.appendField(ConsentExtensionConstants.DATA_SIMPLE, periodTypeArray);
- consentDataJSON.add(jsonElementPeriodType);
- }
+ Object periodicLimit = controlParameters.get(ConsentExtensionConstants.PERIODIC_LIMITS);
- // Constructing jsonElementPeriodicLimits
- JSONObject jsonElementPeriodicLimits = new JSONObject();
- jsonElementPeriodicLimits.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.CONTROL_PARAMETER_AMOUNT_TITLE + periodType);
- JSONArray periodicLimitsArray = new JSONArray();
+ if (periodicLimit instanceof JSONArray) {
+ JSONArray periodicLimitsArrays = (JSONArray) periodicLimit;
- JSONObject periodicLimitsObject = (JSONObject) ((JSONArray) controlParameters
- .get(ConsentExtensionConstants.PERIODIC_LIMITS)).get(0);
+ for (Object periodicLimitObject : periodicLimitsArrays) {
+ if (periodicLimitObject instanceof JSONObject) {
+ JSONObject jsonObject = (JSONObject) periodicLimitObject;
- if (periodicLimitsObject != null) {
- String currency = (String) periodicLimitsObject.get(ConsentExtensionConstants.CURRENCY);
- String amount = (String) periodicLimitsObject.get(ConsentExtensionConstants.AMOUNT);
- String formattedPeriodicAmount = String.format("%s %s", currency, amount);
+ Object periodAlignmentObject = jsonObject.get(ConsentExtensionConstants.PERIOD_ALIGNMENT);
- periodicLimitsArray.add(formattedPeriodicAmount);
+ if (periodAlignmentObject instanceof String) {
+ // Constructing jsonElementPeriodAlignment
+ JSONObject jsonElementPeriodAlignment = new JSONObject();
+ jsonElementPeriodAlignment.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.CONTROL_PARAMETER_PERIOD_ALIGNMENT_TITLE);
- jsonElementPeriodicLimits.appendField(ConsentExtensionConstants.DATA_SIMPLE, periodicLimitsArray);
- consentDataJSON.add(jsonElementPeriodicLimits);
+ JSONArray periodAlignmentArray = new JSONArray();
+ periodAlignmentArray.add(periodAlignmentObject);
- }
+ jsonElementPeriodAlignment.appendField(StringUtils.
+ lowerCase(ConsentExtensionConstants.DATA), periodAlignmentArray);
+ consentDataJSON.add(jsonElementPeriodAlignment);
+ } else {
+ log.error(ErrorConstants.PERIOD_ALIGNMENT_NOT_STRING_ERROR);
+ throw new ConsentException(ResponseStatus.BAD_REQUEST,
+ ErrorConstants.PERIOD_ALIGNMENT_NOT_STRING_ERROR);
+ }
+
+ Object periodTypeObject = jsonObject.get(ConsentExtensionConstants.PERIOD_TYPE);
+
+ if (periodTypeObject instanceof String) {
+
+ JSONObject jsonElementPeriodType = new JSONObject();
+ jsonElementPeriodType.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.CONTROL_PARAMETER_PERIOD_TYPE_TITLE);
+
+ JSONArray periodTypeArray = new JSONArray();
+ periodTypeArray.add(periodTypeObject);
+
+ jsonElementPeriodType.appendField(StringUtils.lowerCase(ConsentExtensionConstants.DATA),
+ periodTypeArray);
+
+ consentDataJSON.add(jsonElementPeriodType);
+
+ } else {
+ log.error(ErrorConstants.PERIOD_TYPE_NOT_STRING_ERROR);
+ throw new ConsentException(ResponseStatus.BAD_REQUEST,
+ ErrorConstants.PERIOD_TYPE_NOT_STRING_ERROR);
+ }
+ // Constructing jsonElementPeriodicLimitsAmountCurrency - periodicLimits amount and currency
+ Object amount = jsonObject.get(ConsentExtensionConstants.AMOUNT);
+ Object currency = jsonObject.get(ConsentExtensionConstants.CURRENCY);
- return consentDataJSON;
+ if (amount instanceof String && currency instanceof String) {
+ String periodTypeString = (String) periodTypeObject;
+ JSONObject jsonElementPeriodicLimitsAmountCurrency = new JSONObject();
+ jsonElementPeriodicLimitsAmountCurrency.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.CONTROL_PARAMETER_AMOUNT_TITLE +
+ periodTypeString);
+
+ JSONArray periodicLimitsArray = new JSONArray();
+
+ String amountString = (String) amount;
+ String currencyString = (String) currency;
+
+ String formattedPeriodicAmount = String.format("%s %s", currencyString, amountString);
+ periodicLimitsArray.add(formattedPeriodicAmount);
+
+ jsonElementPeriodicLimitsAmountCurrency.appendField(StringUtils.
+ lowerCase(ConsentExtensionConstants.DATA), periodicLimitsArray);
+ consentDataJSON.add(jsonElementPeriodicLimitsAmountCurrency);
+
+ } else {
+ log.error(ErrorConstants.NOT_STRING_ERROR);
+ throw new ConsentException(ResponseStatus.BAD_REQUEST,
+ ErrorConstants.NOT_STRING_ERROR);
+ }
+ }
+ }
+ } else {
+ log.error(ErrorConstants.NOT_JSON_ARRAY_ERROR);
+ throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.NOT_JSON_ARRAY_ERROR);
+ }
+ } else {
+ log.error(ErrorConstants.CONTROL_PARAMETERS_MISSING_ERROR);
+ throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.CONTROL_PARAMETERS_MISSING_ERROR);
+ }
}
}
+
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authservlet/impl/OBDefaultAuthServletImpl.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authservlet/impl/OBDefaultAuthServletImpl.java
index 42838db2..54ea3034 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authservlet/impl/OBDefaultAuthServletImpl.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authservlet/impl/OBDefaultAuthServletImpl.java
@@ -74,11 +74,6 @@ public Map updateConsentData(HttpServletRequest request) {
String[] accounts = request.getParameter("accounts[]").split(":");
returnMaps.put("accountIds", new JSONArray(accounts));
- returnMaps.put(ConsentExtensionConstants.PAYMENT_ACCOUNT,
- request.getParameter(ConsentExtensionConstants.PAYMENT_ACCOUNT));
- returnMaps.put(ConsentExtensionConstants.COF_ACCOUNT,
- request.getParameter(ConsentExtensionConstants.COF_ACCOUNT));
-
return returnMaps;
}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authservlet/impl/util/Utils.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authservlet/impl/util/Utils.java
index 2ee28989..b818c1f7 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authservlet/impl/util/Utils.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authservlet/impl/util/Utils.java
@@ -103,7 +103,7 @@ public static Map populateAccountsData(HttpServletRequest reques
for (int requestedDataIndex = 0; requestedDataIndex < dataRequestedJsonArray.length(); requestedDataIndex++) {
JSONObject dataObj = dataRequestedJsonArray.getJSONObject(requestedDataIndex);
String title = dataObj.getString(ConsentExtensionConstants.TITLE);
- JSONArray dataArray = dataObj.getJSONArray(ConsentExtensionConstants.DATA_SIMPLE);
+ JSONArray dataArray = dataObj.getJSONArray(StringUtils.lowerCase(ConsentExtensionConstants.DATA));
ArrayList listData = new ArrayList<>();
for (int dataIndex = 0; dataIndex < dataArray.length(); dataIndex++) {
@@ -140,7 +140,7 @@ public static Map populatePaymentsData(HttpServletRequest reques
for (int requestedDataIndex = 0; requestedDataIndex < dataRequestedJsonArray.length(); requestedDataIndex++) {
JSONObject dataObj = dataRequestedJsonArray.getJSONObject(requestedDataIndex);
String title = dataObj.getString(ConsentExtensionConstants.TITLE);
- JSONArray dataArray = dataObj.getJSONArray(ConsentExtensionConstants.DATA_SIMPLE);
+ JSONArray dataArray = dataObj.getJSONArray(StringUtils.lowerCase(ConsentExtensionConstants.DATA));
ArrayList listData = new ArrayList<>();
for (int dataIndex = 0; dataIndex < dataArray.length(); dataIndex++) {
@@ -182,7 +182,7 @@ public static Map populateCoFData(HttpServletRequest httpServlet
for (int requestedDataIndex = 0; requestedDataIndex < dataRequestedJsonArray.length(); requestedDataIndex++) {
JSONObject dataObj = dataRequestedJsonArray.getJSONObject(requestedDataIndex);
String title = dataObj.getString(ConsentExtensionConstants.TITLE);
- JSONArray dataArray = dataObj.getJSONArray(ConsentExtensionConstants.DATA_SIMPLE);
+ JSONArray dataArray = dataObj.getJSONArray(StringUtils.lowerCase(ConsentExtensionConstants.DATA));
ArrayList listData = new ArrayList<>();
for (int dataIndex = 0; dataIndex < dataArray.length(); dataIndex++) {
@@ -217,7 +217,7 @@ public static String getDebtorAccFromConsentData(JSONArray consentDataObject) {
String title = dataObj.getString(ConsentExtensionConstants.TITLE);
if (ConsentExtensionConstants.DEBTOR_ACC_TITLE.equals(title)) {
- JSONArray dataArray = dataObj.getJSONArray(ConsentExtensionConstants.DATA_SIMPLE);
+ JSONArray dataArray = dataObj.getJSONArray(StringUtils.lowerCase(ConsentExtensionConstants.DATA));
for (int dataIndex = 0; dataIndex < dataArray.length(); dataIndex++) {
String data = (String) dataArray.get(dataIndex);
@@ -269,7 +269,7 @@ public static Map populateVRPDataRetrieval(HttpServletRequest re
for (int requestedDataIndex = 0; requestedDataIndex < dataRequestedJsonArray.length(); requestedDataIndex++) {
JSONObject dataObj = dataRequestedJsonArray.getJSONObject(requestedDataIndex);
String title = dataObj.getString(ConsentExtensionConstants.TITLE);
- JSONArray dataArray = dataObj.getJSONArray(ConsentExtensionConstants.DATA_SIMPLE);
+ JSONArray dataArray = dataObj.getJSONArray(StringUtils.lowerCase(ConsentExtensionConstants.DATA));
ArrayList listData = new ArrayList<>();
for (int dataIndex = 0; dataIndex < dataArray.length(); dataIndex++) {
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/ConsentExtensionConstants.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/ConsentExtensionConstants.java
index 4b05690b..2f44a1a6 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/ConsentExtensionConstants.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/ConsentExtensionConstants.java
@@ -93,7 +93,6 @@ public class ConsentExtensionConstants {
public static final String ACCOUNTS = "accounts";
public static final String CONSENT_DATA = "consentData";
public static final String TITLE = "title";
- public static final String DATA_SIMPLE = "data";
public static final String DEBTOR_ACCOUNT_ID = "AccountId";
public static final String ACCOUNT_ID = "account_id";
public static final String DATA_REQUESTED = "data_requested";
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/factory/AcceleratorConsentExtensionFactory.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/factory/AcceleratorConsentExtensionFactory.java
index 47a00f48..8d8672c9 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/factory/AcceleratorConsentExtensionFactory.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/factory/AcceleratorConsentExtensionFactory.java
@@ -17,14 +17,6 @@
*/
package com.wso2.openbanking.accelerator.consent.extensions.common.factory;
-import com.wso2.openbanking.accelerator.consent.extensions.authorize.impl.handler.persist.AccountConsentPersistenceHandler;
-import com.wso2.openbanking.accelerator.consent.extensions.authorize.impl.handler.persist.CofConsentPersistenceHandler;
-import com.wso2.openbanking.accelerator.consent.extensions.authorize.impl.handler.persist.ConsentPersistenceHandler;
-import com.wso2.openbanking.accelerator.consent.extensions.authorize.impl.handler.persist.PaymentConsentPersistenceHandler;
-import com.wso2.openbanking.accelerator.consent.extensions.authorize.impl.handler.retrieval.AccountConsentRetrievalHandler;
-import com.wso2.openbanking.accelerator.consent.extensions.authorize.impl.handler.retrieval.CofConsentRetrievalHandler;
-import com.wso2.openbanking.accelerator.consent.extensions.authorize.impl.handler.retrieval.ConsentRetrievalHandler;
-import com.wso2.openbanking.accelerator.consent.extensions.authorize.impl.handler.retrieval.PaymentConsentRetrievalHandler;
import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentExtensionConstants;
import com.wso2.openbanking.accelerator.consent.extensions.manage.impl.AccountConsentManageRequestHandler;
import com.wso2.openbanking.accelerator.consent.extensions.manage.impl.CofConsentRequestHandler;
@@ -65,47 +57,4 @@ public static ConsentManageRequestHandler getConsentManageRequestValidator(Strin
return consentManageRequestHandler;
}
-
- /**
- * Method to get the Consent Authorize Handler.
- *
- * @param type Type of the request
- * @return ConsentAuthorizeHandler
- */
- public static ConsentRetrievalHandler getConsentRetrievalHandler(String type) {
-
- ConsentRetrievalHandler consentRetrieveHandler = null;
-
- if (type.equalsIgnoreCase(ConsentExtensionConstants.ACCOUNTS)) {
- consentRetrieveHandler = new AccountConsentRetrievalHandler();
- } else if (type.equalsIgnoreCase(ConsentExtensionConstants.PAYMENTS)) {
- consentRetrieveHandler = new PaymentConsentRetrievalHandler();
- } else if (type.equalsIgnoreCase(ConsentExtensionConstants.FUNDSCONFIRMATIONS)) {
- consentRetrieveHandler = new CofConsentRetrievalHandler();
- }
- return consentRetrieveHandler;
-
- }
-
- /**
- * Method to get the Consent Persistence Handler.
- *
- * @param type Type of the request
- * @return ConsentPersistenceHandler
- */
- public static ConsentPersistenceHandler getConsentPersistenceHandler(String type) {
-
- ConsentPersistenceHandler consentPersistenceHandler = null;
-
- if (ConsentExtensionConstants.ACCOUNTS.equalsIgnoreCase(type)) {
- consentPersistenceHandler = new AccountConsentPersistenceHandler();
- } else if (ConsentExtensionConstants.PAYMENTS.equalsIgnoreCase(type)) {
- consentPersistenceHandler = new PaymentConsentPersistenceHandler();
- } else if (ConsentExtensionConstants.FUNDSCONFIRMATIONS.equalsIgnoreCase(type)) {
- consentPersistenceHandler = new CofConsentPersistenceHandler();
- }
- return consentPersistenceHandler;
-
- }
-
}
From 60a3cf31b74d8d403afc3f384a38b025df5ab085 Mon Sep 17 00:00:00 2001
From: kalpana
Date: Tue, 12 Mar 2024 22:28:48 +0530
Subject: [PATCH 090/281] Resolving the comments for Retrieval flow
---
.../authorize/utils/ConsentRetrievalUtil.java | 4 +--
.../flow/ConsentExtensionDataProvider.java | 18 +++++++++++
.../flow/VRPConsentRetrievalStepTest.java | 32 +++++++++----------
.../utils/ConsentExtensionTestUtils.java | 2 +-
4 files changed, 36 insertions(+), 20 deletions(-)
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/utils/ConsentRetrievalUtil.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/utils/ConsentRetrievalUtil.java
index db7547b3..c07d34e3 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/utils/ConsentRetrievalUtil.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/utils/ConsentRetrievalUtil.java
@@ -1,6 +1,6 @@
/**
* Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
- *
+ *
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
@@ -187,8 +187,6 @@ public static void populateDebtorAccount(JSONObject initiation, JSONArray consen
jsonElementDebtor.appendField(StringUtils.lowerCase(ConsentExtensionConstants.DATA), debtorAccountArray);
consentDataJSON.add(jsonElementDebtor);
}
-
-
}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/ConsentExtensionDataProvider.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/ConsentExtensionDataProvider.java
index 7d1a739e..eb9488d9 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/ConsentExtensionDataProvider.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/ConsentExtensionDataProvider.java
@@ -1,6 +1,24 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package com.wso2.openbanking.accelerator.consent.extensions.authorize.vrp.retrieval.flow;
import org.testng.annotations.DataProvider;
+
/**
* Data Provider for Consent Executor Tests.
*/
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/VRPConsentRetrievalStepTest.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/VRPConsentRetrievalStepTest.java
index aefacc40..2d4a9639 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/VRPConsentRetrievalStepTest.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/VRPConsentRetrievalStepTest.java
@@ -1,13 +1,13 @@
/**
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
- *
+ *
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -273,19 +273,19 @@ public void testGetConsentDataSetForCOF() throws ConsentManagementException, Par
Assert.assertNotNull(cofConsentData);
}
- @Test
- public void testGetConsentDataSetForVRP() throws ConsentManagementException, ParseException {
-
- Mockito.doReturn(ConsentExtensionConstants.VRP).when(consentResourceMock).getConsentType();
- Mockito.doReturn(ConsentAuthorizeTestConstants.VRP_INITIATION).when(consentResourceMock)
- .getReceipt();
- Mockito.doReturn(ConsentAuthorizeTestConstants.AWAITING_AUTH_STATUS).when(consentResourceMock)
- .getCurrentStatus();
-
- JSONArray cofConsentData = defaultConsentRetrievalStep.getConsentDataSet(consentResourceMock);
-
- Assert.assertNotNull(cofConsentData);
- }
+// @Test
+// public void testGetConsentDataSetForVRP() {
+//
+// Mockito.doReturn(ConsentExtensionConstants.VRP).when(consentResourceMock).getConsentType();
+// Mockito.doReturn(ConsentAuthorizeTestConstants.VRP_INITIATION).when(consentResourceMock)
+// .getReceipt();
+// Mockito.doReturn(ConsentAuthorizeTestConstants.AWAITING_AUTH_STATUS).when(consentResourceMock)
+// .getCurrentStatus();
+//
+// JSONArray cofConsentData = defaultConsentRetrievalStep.getConsentDataSet(consentResourceMock);
+//
+// Assert.assertNotNull(cofConsentData);
+// }
}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/utils/ConsentExtensionTestUtils.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/utils/ConsentExtensionTestUtils.java
index 7b3c383c..ca8c06aa 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/utils/ConsentExtensionTestUtils.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/utils/ConsentExtensionTestUtils.java
@@ -22,7 +22,7 @@
import java.util.Map;
/**
- * comment.
+ * Utils class for consent executor tests.
*/
public class ConsentExtensionTestUtils {
From 5f6d81b3661ee8ee53abe50dcaa44f36453392c1 Mon Sep 17 00:00:00 2001
From: kalpana
Date: Wed, 13 Mar 2024 09:35:02 +0530
Subject: [PATCH 091/281] Resolving the comments for Retrieval flow
---
.../flow/VRPConsentRetrievalStepTest.java | 26 +++++++++----------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/VRPConsentRetrievalStepTest.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/VRPConsentRetrievalStepTest.java
index 2d4a9639..9424536f 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/VRPConsentRetrievalStepTest.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/VRPConsentRetrievalStepTest.java
@@ -273,19 +273,19 @@ public void testGetConsentDataSetForCOF() throws ConsentManagementException, Par
Assert.assertNotNull(cofConsentData);
}
-// @Test
-// public void testGetConsentDataSetForVRP() {
-//
-// Mockito.doReturn(ConsentExtensionConstants.VRP).when(consentResourceMock).getConsentType();
-// Mockito.doReturn(ConsentAuthorizeTestConstants.VRP_INITIATION).when(consentResourceMock)
-// .getReceipt();
-// Mockito.doReturn(ConsentAuthorizeTestConstants.AWAITING_AUTH_STATUS).when(consentResourceMock)
-// .getCurrentStatus();
-//
-// JSONArray cofConsentData = defaultConsentRetrievalStep.getConsentDataSet(consentResourceMock);
-//
-// Assert.assertNotNull(cofConsentData);
-// }
+ @Test
+ public void testGetConsentDataSetForVRP() {
+
+ Mockito.doReturn(ConsentExtensionConstants.VRP).when(consentResourceMock).getConsentType();
+ Mockito.doReturn(ConsentAuthorizeTestConstants.VRP_INITIATION).when(consentResourceMock)
+ .getReceipt();
+ Mockito.doReturn(ConsentAuthorizeTestConstants.AWAITING_AUTH_STATUS).when(consentResourceMock)
+ .getCurrentStatus();
+
+ JSONArray cofConsentData = defaultConsentRetrievalStep.getConsentDataSet(consentResourceMock);
+
+ Assert.assertNotNull(cofConsentData);
+ }
}
From 4800926959c1fffca214e48f076e24a10fcb6d01 Mon Sep 17 00:00:00 2001
From: kalpana
Date: Wed, 13 Mar 2024 12:21:29 +0530
Subject: [PATCH 092/281] Removal of Retrieval handler classes present in the
Retrieval Flow
---
.../AccountConsentRetrievalHandler.java | 139 -------------
.../retrieval/CofConsentRetrievalHandler.java | 149 -------------
.../retrieval/ConsentRetrievalHandler.java | 43 ----
.../PaymentConsentRetrievalHandler.java | 195 ------------------
4 files changed, 526 deletions(-)
delete mode 100644 open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/handler/retrieval/AccountConsentRetrievalHandler.java
delete mode 100644 open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/handler/retrieval/CofConsentRetrievalHandler.java
delete mode 100644 open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/handler/retrieval/ConsentRetrievalHandler.java
delete mode 100644 open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/handler/retrieval/PaymentConsentRetrievalHandler.java
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/handler/retrieval/AccountConsentRetrievalHandler.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/handler/retrieval/AccountConsentRetrievalHandler.java
deleted file mode 100644
index b73be77f..00000000
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/handler/retrieval/AccountConsentRetrievalHandler.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/**
- * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
- *
- * WSO2 LLC. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package com.wso2.openbanking.accelerator.consent.extensions.authorize.impl.handler.retrieval;
-
-
-import com.wso2.openbanking.accelerator.common.util.ErrorConstants;
-import com.wso2.openbanking.accelerator.consent.extensions.authorize.utils.ConsentRetrievalUtil;
-import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentException;
-import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentExtensionConstants;
-import com.wso2.openbanking.accelerator.consent.extensions.common.ResponseStatus;
-import com.wso2.openbanking.accelerator.consent.mgt.dao.models.ConsentResource;
-import net.minidev.json.JSONArray;
-import net.minidev.json.JSONObject;
-import net.minidev.json.parser.JSONParser;
-import net.minidev.json.parser.ParseException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-
-/**
- * Class to handle Account Consent data retrieval for Authorize.
- */
-public class AccountConsentRetrievalHandler implements ConsentRetrievalHandler {
-
- private static final Log log = LogFactory.getLog(AccountConsentRetrievalHandler.class);
-
- /**
- * Method defined to retrieve the Account consent related data in the authorization flow to send them to the.
- * consent page to get PSU consent
- *
- * @param consentResource Consent Resource parameter containing consent related information retrieved from database
- * @return consentDataJSON
- * @throws ConsentException
- */
- @Override
- public JSONArray getConsentDataSet(ConsentResource consentResource)
- throws ConsentException {
-
- try {
- String receiptString = consentResource.getReceipt();
- Object receiptJSON = new JSONParser(JSONParser.MODE_PERMISSIVE).parse(receiptString);
-
- //Checking whether the request body is in JSON format
- if (!(receiptJSON instanceof JSONObject)) {
- log.error(ErrorConstants.NOT_JSON_OBJECT_ERROR);
- throw new ConsentException(ResponseStatus.INTERNAL_SERVER_ERROR, ErrorConstants.NOT_JSON_OBJECT_ERROR);
- }
-
- //Checking whether the consent status is valid
- if (!consentResource.getCurrentStatus().equals(ConsentExtensionConstants.AWAITING_AUTH_STATUS)) {
- log.error(ErrorConstants.STATE_INVALID_ERROR);
- //Currently throwing error as 400 response. Developer also have the option of appending a field IS_ERROR
- // to the jsonObject and showing it to the user in the webapp. If so, the IS_ERROR have to be checked in
- // any later steps.
- throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.STATE_INVALID_ERROR);
- }
-
- JSONArray consentDataJSON = new JSONArray();
-
- JSONObject receipt = (JSONObject) receiptJSON;
-
- //Adding Permissions
- JSONObject data = (JSONObject) receipt.get(ConsentExtensionConstants.DATA);
- JSONArray permissions = (JSONArray) data.get(ConsentExtensionConstants.PERMISSIONS);
- JSONObject jsonElementPermissions = new JSONObject();
- jsonElementPermissions.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.PERMISSIONS);
- jsonElementPermissions.appendField(ConsentExtensionConstants.DATA_SIMPLE, permissions);
- consentDataJSON.add(jsonElementPermissions);
-
- //Adding Expiration Date Time
- if (data.getAsString(ConsentExtensionConstants.EXPIRATION_DATE) != null) {
-
- if (!ConsentRetrievalUtil
- .validateExpiryDateTime(data.getAsString(ConsentExtensionConstants.EXPIRATION_DATE))) {
- log.error(ErrorConstants.CONSENT_EXPIRED);
- throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.CONSENT_EXPIRED);
- }
- String expiry = data.getAsString(ConsentExtensionConstants.EXPIRATION_DATE);
- JSONArray expiryArray = new JSONArray();
- expiryArray.add(expiry);
-
- JSONObject jsonElementExpiry = new JSONObject();
- jsonElementExpiry.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.EXPIRATION_DATE_TITLE);
- jsonElementExpiry.appendField(ConsentExtensionConstants.DATA_SIMPLE, expiryArray);
- consentDataJSON.add(jsonElementExpiry);
- }
-
- //Adding Transaction From Date Time
- if (data.getAsString(ConsentExtensionConstants.TRANSACTION_FROM_DATE) != null) {
- String fromDateTime = data.getAsString(ConsentExtensionConstants.TRANSACTION_FROM_DATE);
- JSONArray fromDateTimeArray = new JSONArray();
- fromDateTimeArray.add(fromDateTime);
-
- JSONObject jsonElementFromDateTime = new JSONObject();
- jsonElementFromDateTime.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.TRANSACTION_FROM_DATE_TITLE);
- jsonElementFromDateTime.appendField(ConsentExtensionConstants.DATA_SIMPLE, fromDateTimeArray);
- consentDataJSON.add(jsonElementFromDateTime);
- }
-
- //Adding Transaction To Date Time
- if (data.getAsString(ConsentExtensionConstants.TRANSACTION_TO_DATE) != null) {
- String toDateTime = data.getAsString(ConsentExtensionConstants.TRANSACTION_TO_DATE);
- JSONArray toDateTimeArray = new JSONArray();
- toDateTimeArray.add(toDateTime);
-
- JSONObject jsonElementToDateTime = new JSONObject();
- jsonElementToDateTime.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.TRANSACTION_TO_DATE_TITLE);
- jsonElementToDateTime.appendField(ConsentExtensionConstants.DATA_SIMPLE, toDateTimeArray);
- consentDataJSON.add(jsonElementToDateTime);
- }
-
- return consentDataJSON;
- } catch (ParseException e) {
- log.error("Exception occurred while getting consent data. Caused by: ", e);
- throw new ConsentException(ResponseStatus.INTERNAL_SERVER_ERROR, ErrorConstants.CONSENT_RETRIEVAL_ERROR);
- }
- }
-}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/handler/retrieval/CofConsentRetrievalHandler.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/handler/retrieval/CofConsentRetrievalHandler.java
deleted file mode 100644
index 73f1017c..00000000
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/handler/retrieval/CofConsentRetrievalHandler.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/**
- * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
- *
- * WSO2 LLC. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package com.wso2.openbanking.accelerator.consent.extensions.authorize.impl.handler.retrieval;
-
-import com.wso2.openbanking.accelerator.common.util.ErrorConstants;
-import com.wso2.openbanking.accelerator.consent.extensions.authorize.utils.ConsentRetrievalUtil;
-import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentException;
-import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentExtensionConstants;
-import com.wso2.openbanking.accelerator.consent.extensions.common.ResponseStatus;
-import com.wso2.openbanking.accelerator.consent.mgt.dao.models.ConsentResource;
-import net.minidev.json.JSONArray;
-import net.minidev.json.JSONObject;
-import net.minidev.json.parser.JSONParser;
-import net.minidev.json.parser.ParseException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Class to handle Confirmation of Funds Consent data retrieval for Authorize.
- */
-public class CofConsentRetrievalHandler implements ConsentRetrievalHandler {
-
- private static final Log log = LogFactory.getLog(CofConsentRetrievalHandler.class);
-
- /**
- * Method defined to retrieve the COF consent related data in the authorization flow to send them to the
- * consent page to get PSU consent.
- *
- * @param consentResource Consent Resource parameter containing consent related information retrieved from database
- * @return
- * @throws ConsentException
- */
- @Override
- public JSONArray getConsentDataSet(ConsentResource consentResource) throws ConsentException {
-
- try {
- String receiptString = consentResource.getReceipt();
- Object receiptJSON = new JSONParser(JSONParser.MODE_PERMISSIVE).parse(receiptString);
-
- //Checking whether the request body is in JSON format
- if (!(receiptJSON instanceof JSONObject)) {
- log.error(ErrorConstants.NOT_JSON_OBJECT_ERROR);
- throw new ConsentException(ResponseStatus.INTERNAL_SERVER_ERROR, ErrorConstants.NOT_JSON_OBJECT_ERROR);
- }
-
- //Checking whether the consent status is valid
- if (!consentResource.getCurrentStatus().equals(ConsentExtensionConstants.AWAITING_AUTH_STATUS) &&
- !consentResource.getCurrentStatus().equals(ConsentExtensionConstants.AUTHORIZED_STATUS)) {
- log.error(ErrorConstants.STATE_INVALID_ERROR);
- //Currently throwing error as 400 response. Developer also have the option of appending a field IS_ERROR
- // to the jsonObject and showing it to the user in the webapp. If so, the IS_ERROR have to be checked in
- // any later steps.
- throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.STATE_INVALID_ERROR);
- }
-
- JSONArray consentDataJSON = new JSONArray();
- JSONObject receipt = (JSONObject) receiptJSON;
- JSONObject data = (JSONObject) receipt.get(ConsentExtensionConstants.DATA);
-
- //Adding Expiration Date Time
- if (data.getAsString(ConsentExtensionConstants.EXPIRATION_DATE) != null) {
-
- if (!ConsentRetrievalUtil
- .validateExpiryDateTime(data.getAsString(ConsentExtensionConstants.EXPIRATION_DATE))) {
- log.error(ErrorConstants.CONSENT_EXPIRED);
- throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.CONSENT_EXPIRED);
- }
-
- String expiry = data.getAsString(ConsentExtensionConstants.EXPIRATION_DATE);
- JSONArray expiryArray = new JSONArray();
- expiryArray.add(expiry);
-
- JSONObject jsonElementExpiry = new JSONObject();
- jsonElementExpiry.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.EXPIRATION_DATE_TITLE);
- jsonElementExpiry.appendField(ConsentExtensionConstants.DATA_SIMPLE, expiryArray);
- consentDataJSON.add(jsonElementExpiry);
- } else {
- JSONArray expiryArray = new JSONArray();
- expiryArray.add(ConsentExtensionConstants.OPEN_ENDED_AUTHORIZATION);
-
- JSONObject jsonElementExpiry = new JSONObject();
- jsonElementExpiry.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.EXPIRATION_DATE_TITLE);
- jsonElementExpiry.appendField(ConsentExtensionConstants.DATA_SIMPLE, expiryArray);
- consentDataJSON.add(jsonElementExpiry);
- }
-
- //Adding Debtor Account
- if (data.get(ConsentExtensionConstants.DEBTOR_ACC) != null) {
- JSONObject debtorAccount = (JSONObject) data.get(ConsentExtensionConstants.DEBTOR_ACC);
- JSONArray debtorAccountArray = new JSONArray();
- //Adding Debtor Account Scheme Name
- if (debtorAccount.getAsString(ConsentExtensionConstants.SCHEME_NAME) != null) {
- debtorAccountArray.add(ConsentExtensionConstants.SCHEME_NAME_TITLE + " : " +
- debtorAccount.getAsString(ConsentExtensionConstants.SCHEME_NAME));
- }
- //Adding Debtor Account Identification
- if (debtorAccount.getAsString(ConsentExtensionConstants.IDENTIFICATION) != null) {
- debtorAccountArray.add(ConsentExtensionConstants.IDENTIFICATION_TITLE + " : " +
- debtorAccount.getAsString(ConsentExtensionConstants.IDENTIFICATION));
- }
- //Adding Debtor Account Name
- if (debtorAccount.getAsString(ConsentExtensionConstants.NAME) != null) {
- debtorAccountArray.add(ConsentExtensionConstants.NAME_TITLE + " : " +
- debtorAccount.getAsString(ConsentExtensionConstants.NAME));
- }
- //Adding Debtor Account Secondary Identification
- if (debtorAccount.getAsString(ConsentExtensionConstants.SECONDARY_IDENTIFICATION) != null) {
- debtorAccountArray.add(ConsentExtensionConstants.SECONDARY_IDENTIFICATION_TITLE + " : " +
- debtorAccount.getAsString(ConsentExtensionConstants.SECONDARY_IDENTIFICATION));
- }
-
- JSONObject jsonElementDebtor = new JSONObject();
- jsonElementDebtor.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.DEBTOR_ACC_TITLE);
- jsonElementDebtor.appendField(ConsentExtensionConstants.DATA_SIMPLE, debtorAccountArray);
- consentDataJSON.add(jsonElementDebtor);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("Returned consent data to get the PSU consent " + consentDataJSON);
- }
-
- return consentDataJSON;
- } catch (ParseException e) {
- log.error("Exception occurred while getting consent data. Caused by : ", e);
- throw new ConsentException(ResponseStatus.INTERNAL_SERVER_ERROR, ErrorConstants.CONSENT_RETRIEVAL_ERROR);
- }
- }
-
-}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/handler/retrieval/ConsentRetrievalHandler.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/handler/retrieval/ConsentRetrievalHandler.java
deleted file mode 100644
index 2cb0375b..00000000
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/handler/retrieval/ConsentRetrievalHandler.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
- *
- * WSO2 LLC. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package com.wso2.openbanking.accelerator.consent.extensions.authorize.impl.handler.retrieval;
-
-
-import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentException;
-import com.wso2.openbanking.accelerator.consent.mgt.dao.models.ConsentResource;
-import net.minidev.json.JSONArray;
-
-
-/**
- * Interface to handle Consent data retrieval for Authorize.
- */
-public interface ConsentRetrievalHandler {
-
- /**
- * Abstract method defined to retrieve the consent related data in the authorization flow to send them to the
- * consent page to get PSU consent.
- *
- * @param consentResource Consent Resource parameter containing consent related information retrieved from database
- * @return
- * @throws ConsentException
- */
- JSONArray getConsentDataSet(ConsentResource consentResource) throws ConsentException;
-
-}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/handler/retrieval/PaymentConsentRetrievalHandler.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/handler/retrieval/PaymentConsentRetrievalHandler.java
deleted file mode 100644
index cff4e09e..00000000
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/impl/handler/retrieval/PaymentConsentRetrievalHandler.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/**
- * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
- *
- * WSO2 LLC. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package com.wso2.openbanking.accelerator.consent.extensions.authorize.impl.handler.retrieval;
-
-import com.wso2.openbanking.accelerator.common.exception.ConsentManagementException;
-import com.wso2.openbanking.accelerator.common.util.ErrorConstants;
-import com.wso2.openbanking.accelerator.consent.extensions.authorize.utils.ConsentRetrievalUtil;
-import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentException;
-import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentExtensionConstants;
-import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentExtensionUtils;
-import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentServiceUtil;
-import com.wso2.openbanking.accelerator.consent.extensions.common.ResponseStatus;
-import com.wso2.openbanking.accelerator.consent.mgt.dao.models.ConsentResource;
-import net.minidev.json.JSONArray;
-import net.minidev.json.JSONObject;
-import net.minidev.json.parser.JSONParser;
-import net.minidev.json.parser.ParseException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Class to handle Payment Consent data retrieval for Authorize.
- */
-public class PaymentConsentRetrievalHandler implements ConsentRetrievalHandler {
-
- private static final Log log = LogFactory.getLog(PaymentConsentRetrievalHandler.class);
-
-
- /**
- * Method defined to retrieve the Payment consent related data in the authorization flow to send them to the.
- * consent page to get PSU consent
- *
- * @param consentResource Consent Resource parameter containing consent related information retrieved from database
- * @return
- * @throws ConsentException
- */
- @Override
- public JSONArray getConsentDataSet(ConsentResource consentResource) {
-
- try {
- String receiptString = consentResource.getReceipt();
- Object receiptJSON = new JSONParser(JSONParser.MODE_PERMISSIVE).parse(receiptString);
-
- //Checking whether the request body is in JSON format
- if (!(receiptJSON instanceof JSONObject)) {
- log.error(ErrorConstants.NOT_JSON_OBJECT_ERROR);
- throw new ConsentException(ResponseStatus.INTERNAL_SERVER_ERROR, ErrorConstants.NOT_JSON_OBJECT_ERROR);
- }
-
- //Checking whether the consent status is valid
- if (!consentResource.getCurrentStatus().equals(ConsentExtensionConstants.AWAITING_AUTH_STATUS)) {
- log.error(ErrorConstants.STATE_INVALID_ERROR);
- //Currently throwing error as 400 response. Developer also have the option of appending a field IS_ERROR
- // to the jsonObject and showing it to the user in the webapp. If so, the IS_ERROR have to be checked in
- // any later steps.
- throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.STATE_INVALID_ERROR);
- }
-
- JSONArray consentDataJSON = new JSONArray();
- JSONObject receipt = (JSONObject) receiptJSON;
- JSONObject data = (JSONObject) receipt.get(ConsentExtensionConstants.DATA);
- JSONObject initiation = (JSONObject) data.get(ConsentExtensionConstants.INITIATION);
-
- // Rejecting consent if cut off time is elapsed and the policy is REJECT
- // Updating the consent status to "Reject" if the above condition is true
- if (ConsentExtensionUtils.shouldSubmissionRequestBeRejected(ConsentExtensionUtils
- .convertToISO8601(consentResource.getCreatedTime()))) {
- boolean success = ConsentServiceUtil.getConsentService()
- .revokeConsent(consentResource.getConsentID(), ConsentExtensionConstants.REJECTED_STATUS);
- if (!success) {
- log.error(ErrorConstants.AUTH_TOKEN_REVOKE_ERROR);
- throw new ConsentException(ResponseStatus.INTERNAL_SERVER_ERROR,
- ErrorConstants.AUTH_TOKEN_REVOKE_ERROR);
- }
- log.error(ErrorConstants.AUTH_CUT_OFF_DATE_ELAPSED);
- throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.AUTH_CUT_OFF_DATE_ELAPSED);
- }
-
- consentDataJSON = populateSinglePaymentData(initiation, consentDataJSON);
- //Adding Debtor Account
- ConsentRetrievalUtil.populateDebtorAccount(initiation, consentDataJSON);
-
- //Adding Creditor Account
- ConsentRetrievalUtil.populateCreditorAccount(initiation, consentDataJSON);
-
- return consentDataJSON;
- } catch (ParseException | ConsentManagementException e) {
- throw new ConsentException(ResponseStatus.INTERNAL_SERVER_ERROR, ErrorConstants.CONSENT_RETRIEVAL_ERROR);
- }
- }
-
- /**
- * Populate Domestic and international Payment Details.
- *
- * @param data Initiation request from th request
- * @param consentDataJSON Consent information
- */
- private static JSONArray populateSinglePaymentData(JSONObject data, JSONArray consentDataJSON) {
-
- JSONArray paymentTypeArray = new JSONArray();
- JSONObject jsonElementPaymentType = new JSONObject();
-
- if (data.containsKey(ConsentExtensionConstants.CURRENCY_OF_TRANSFER)) {
- //For International Payments
- //Adding Payment Type
- paymentTypeArray.add(ConsentExtensionConstants.INTERNATIONAL_PAYMENTS);
-
- jsonElementPaymentType.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.PAYMENT_TYPE_TITLE);
- jsonElementPaymentType.appendField(ConsentExtensionConstants.DATA_SIMPLE, paymentTypeArray);
- consentDataJSON.add(jsonElementPaymentType);
-
- //Adding Currency Of Transfer
- JSONArray currencyTransferArray = new JSONArray();
- currencyTransferArray.add(data.getAsString(ConsentExtensionConstants.CURRENCY_OF_TRANSFER));
-
- JSONObject jsonElementCurTransfer = new JSONObject();
- jsonElementCurTransfer.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.CURRENCY_OF_TRANSFER_TITLE);
- jsonElementCurTransfer.appendField(ConsentExtensionConstants.DATA_SIMPLE, currencyTransferArray);
- consentDataJSON.add(jsonElementCurTransfer);
- } else {
- //Adding Payment Type
- paymentTypeArray.add(ConsentExtensionConstants.DOMESTIC_PAYMENTS);
-
- jsonElementPaymentType.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.PAYMENT_TYPE_TITLE);
- jsonElementPaymentType.appendField(ConsentExtensionConstants.DATA_SIMPLE, paymentTypeArray);
- consentDataJSON.add(jsonElementPaymentType);
- }
-
- //Adding InstructionIdentification
- JSONArray identificationArray = new JSONArray();
- identificationArray.add(data.getAsString(ConsentExtensionConstants.INSTRUCTION_IDENTIFICATION));
-
- JSONObject jsonElementIdentification = new JSONObject();
- jsonElementIdentification.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.INSTRUCTION_IDENTIFICATION_TITLE);
- jsonElementIdentification.appendField(ConsentExtensionConstants.DATA_SIMPLE, identificationArray);
- consentDataJSON.add(jsonElementIdentification);
-
- //Adding EndToEndIdentification
- JSONArray endToEndIdentificationArray = new JSONArray();
- endToEndIdentificationArray
- .add(data.getAsString(ConsentExtensionConstants.END_TO_END_IDENTIFICATION));
-
- JSONObject jsonElementEndToEndIdentification = new JSONObject();
- jsonElementEndToEndIdentification.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.END_TO_END_IDENTIFICATION_TITLE);
- jsonElementEndToEndIdentification.appendField(ConsentExtensionConstants.DATA_SIMPLE,
- endToEndIdentificationArray);
- consentDataJSON.add(jsonElementEndToEndIdentification);
-
- //Adding InstructedAmount
- JSONObject instructedAmount = (JSONObject) data.get(ConsentExtensionConstants.INSTRUCTED_AMOUNT);
- JSONArray instructedAmountArray = new JSONArray();
-
- if (instructedAmount.getAsString(ConsentExtensionConstants.AMOUNT_TITLE) != null) {
- instructedAmountArray.add(ConsentExtensionConstants.AMOUNT_TITLE + " : " +
- instructedAmount.getAsString(ConsentExtensionConstants.AMOUNT));
- }
-
- if (instructedAmount.getAsString(ConsentExtensionConstants.CURRENCY) != null) {
- instructedAmountArray.add(ConsentExtensionConstants.CURRENCY_TITLE + " : " +
- instructedAmount.getAsString(ConsentExtensionConstants.CURRENCY));
- }
-
- JSONObject jsonElementInstructedAmount = new JSONObject();
- jsonElementInstructedAmount.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.INSTRUCTED_AMOUNT_TITLE);
- jsonElementInstructedAmount.appendField(ConsentExtensionConstants.DATA_SIMPLE, instructedAmountArray);
- consentDataJSON.add(jsonElementInstructedAmount);
-
- return consentDataJSON;
- }
-
-}
-
From 01f2f082523407a64722c7ecaf927ccfcbb2d15f Mon Sep 17 00:00:00 2001
From: kalpana
Date: Thu, 14 Mar 2024 09:13:16 +0530
Subject: [PATCH 093/281] Resolving the comments
---
.../authorize/utils/ConsentRetrievalUtil.java | 56 +++++++++----------
.../AcceleratorConsentExtensionFactory.java | 24 ++++++++
2 files changed, 50 insertions(+), 30 deletions(-)
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/utils/ConsentRetrievalUtil.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/utils/ConsentRetrievalUtil.java
index c07d34e3..7d8c67ed 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/utils/ConsentRetrievalUtil.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/utils/ConsentRetrievalUtil.java
@@ -58,7 +58,7 @@ public static String extractRequestObject(String spQueryParams) {
for (String param : spQueries) {
if (param.contains("request=")) {
requestObject = (param.substring("request=".length())).replaceAll(
- "\\r\\n|\\r|\\n|%20", "");
+ "\\r\\n|\\r|\\n|\\%20", "");
}
}
if (requestObject != null) {
@@ -261,10 +261,10 @@ public static JSONArray appendDummyAccountID() {
* this method also invokes the relevant methods to populate data for each flow.
*
* @param consentResource Consent Resource parameter containing consent related information retrieved
- * from database
+ * from database.
* @return ConsentDataJson array
*/
- public static JSONArray getConsentData(ConsentResource consentResource) throws ConsentException {
+ public static JSONArray getConsentData(ConsentResource consentResource) throws ConsentException {
JSONArray consentDataJSON = new JSONArray();
try {
@@ -314,17 +314,14 @@ public static JSONArray getConsentData(ConsentResource consentResource) throws
log.error(ErrorConstants.DATA_OBJECT_MISSING_ERROR);
throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.DATA_OBJECT_MISSING_ERROR);
}
-
} catch (ParseException e) {
log.error(ErrorConstants.CONSENT_RETRIEVAL_ERROR, e);
throw new ConsentException(ResponseStatus.INTERNAL_SERVER_ERROR,
ErrorConstants.CONSENT_RETRIEVAL_ERROR);
}
-
return consentDataJSON;
}
-
/**
* Populate Domestic and international Payment Details.
*
@@ -544,7 +541,11 @@ private static void populateCofData(JSONObject initiation, JSONArray consentData
*/
private static void populateVRPData(JSONObject data, JSONArray consentDataJSON) {
- if (data.containsKey(ConsentExtensionConstants.CONTROL_PARAMETERS)) {
+ if (!data.containsKey(ConsentExtensionConstants.CONTROL_PARAMETERS)) {
+ log.error(ErrorConstants.CONTROL_PARAMETERS_MISSING_ERROR);
+ throw new ConsentException(ResponseStatus.BAD_REQUEST,
+ ErrorConstants.CONTROL_PARAMETERS_MISSING_ERROR);
+ } else {
JSONObject controlParameters = (JSONObject) data.
get(ConsentExtensionConstants.CONTROL_PARAMETERS);
@@ -591,27 +592,27 @@ private static void populateVRPData(JSONObject data, JSONArray consentDataJSON)
Object maxAmount = controlParameters.get(ConsentExtensionConstants.MAXIMUM_INDIVIDUAL_AMOUNT);
- if (maxAmount instanceof JSONObject) {
- JSONObject jsonElementControlParameter = new JSONObject();
- jsonElementControlParameter.appendField(ConsentExtensionConstants.TITLE,
- ConsentExtensionConstants.CONTROL_PARAMETER_MAX_INDIVIDUAL_AMOUNT_TITLE);
- JSONArray controlParameterArray = new JSONArray();
+ if (maxAmount instanceof JSONObject) {
+ JSONObject jsonElementControlParameter = new JSONObject();
+ jsonElementControlParameter.appendField(ConsentExtensionConstants.TITLE,
+ ConsentExtensionConstants.CONTROL_PARAMETER_MAX_INDIVIDUAL_AMOUNT_TITLE);
+ JSONArray controlParameterArray = new JSONArray();
- JSONObject maximumIndividualAmount = (JSONObject) maxAmount;
+ JSONObject maximumIndividualAmount = (JSONObject) maxAmount;
- String formattedAmount = String.format("%s %s",
- maximumIndividualAmount.getAsString(ConsentExtensionConstants.CURRENCY),
- maximumIndividualAmount.getAsString(ConsentExtensionConstants.AMOUNT));
- controlParameterArray.add(formattedAmount);
- jsonElementControlParameter.appendField(StringUtils.lowerCase(ConsentExtensionConstants.DATA),
- controlParameterArray);
+ String formattedAmount = String.format("%s %s",
+ maximumIndividualAmount.getAsString(ConsentExtensionConstants.CURRENCY),
+ maximumIndividualAmount.getAsString(ConsentExtensionConstants.AMOUNT));
+ controlParameterArray.add(formattedAmount);
+ jsonElementControlParameter.appendField(StringUtils.lowerCase(ConsentExtensionConstants.DATA),
+ controlParameterArray);
- consentDataJSON.add(jsonElementControlParameter);
- } else {
- log.error(ErrorConstants.MAX_AMOUNT_NOT_JSON_OBJECT_ERROR);
- throw new ConsentException(ResponseStatus.BAD_REQUEST,
- ErrorConstants.MAX_AMOUNT_NOT_JSON_OBJECT_ERROR);
- }
+ consentDataJSON.add(jsonElementControlParameter);
+ } else {
+ log.error(ErrorConstants.MAX_AMOUNT_NOT_JSON_OBJECT_ERROR);
+ throw new ConsentException(ResponseStatus.BAD_REQUEST,
+ ErrorConstants.MAX_AMOUNT_NOT_JSON_OBJECT_ERROR);
+ }
Object periodicLimit = controlParameters.get(ConsentExtensionConstants.PERIODIC_LIMITS);
@@ -698,11 +699,6 @@ private static void populateVRPData(JSONObject data, JSONArray consentDataJSON)
log.error(ErrorConstants.NOT_JSON_ARRAY_ERROR);
throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.NOT_JSON_ARRAY_ERROR);
}
- } else {
- log.error(ErrorConstants.CONTROL_PARAMETERS_MISSING_ERROR);
- throw new ConsentException(ResponseStatus.BAD_REQUEST, ErrorConstants.CONTROL_PARAMETERS_MISSING_ERROR);
}
}
}
-
-
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/factory/AcceleratorConsentExtensionFactory.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/factory/AcceleratorConsentExtensionFactory.java
index 8d8672c9..7ca7e3a5 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/factory/AcceleratorConsentExtensionFactory.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/factory/AcceleratorConsentExtensionFactory.java
@@ -17,6 +17,10 @@
*/
package com.wso2.openbanking.accelerator.consent.extensions.common.factory;
+import com.wso2.openbanking.accelerator.consent.extensions.authorize.impl.handler.persist.AccountConsentPersistenceHandler;
+import com.wso2.openbanking.accelerator.consent.extensions.authorize.impl.handler.persist.CofConsentPersistenceHandler;
+import com.wso2.openbanking.accelerator.consent.extensions.authorize.impl.handler.persist.ConsentPersistenceHandler;
+import com.wso2.openbanking.accelerator.consent.extensions.authorize.impl.handler.persist.PaymentConsentPersistenceHandler;
import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentExtensionConstants;
import com.wso2.openbanking.accelerator.consent.extensions.manage.impl.AccountConsentManageRequestHandler;
import com.wso2.openbanking.accelerator.consent.extensions.manage.impl.CofConsentRequestHandler;
@@ -57,4 +61,24 @@ public static ConsentManageRequestHandler getConsentManageRequestValidator(Strin
return consentManageRequestHandler;
}
+
+ /**
+ * Method to get the Consent Persistence Handler.
+ *
+ * @param type Type of the request
+ * @return ConsentPersistenceHandler
+ */
+ public static ConsentPersistenceHandler getConsentPersistenceHandler(String type) {
+ ConsentPersistenceHandler consentPersistenceHandler = null;
+
+ if (ConsentExtensionConstants.ACCOUNTS.equalsIgnoreCase(type)) {
+ consentPersistenceHandler = new AccountConsentPersistenceHandler();
+ } else if (ConsentExtensionConstants.PAYMENTS.equalsIgnoreCase(type)) {
+ consentPersistenceHandler = new PaymentConsentPersistenceHandler();
+ } else if (ConsentExtensionConstants.FUNDSCONFIRMATIONS.equalsIgnoreCase(type)) {
+ consentPersistenceHandler = new CofConsentPersistenceHandler();
+ }
+ return consentPersistenceHandler;
+
+ }
}
From 02c291de93a1343aaec0c580675f0b4c8c0a9248 Mon Sep 17 00:00:00 2001
From: kalpana
Date: Thu, 14 Mar 2024 09:27:24 +0530
Subject: [PATCH 094/281] Resolving the comments
---
.../vrp/retrieval/flow/VRPConsentRetrievalUtilTest.java | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/VRPConsentRetrievalUtilTest.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/VRPConsentRetrievalUtilTest.java
index c929e07c..3c441a6d 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/VRPConsentRetrievalUtilTest.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/VRPConsentRetrievalUtilTest.java
@@ -1,13 +1,13 @@
/**
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
- *
+ *
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
- *
- * Handles the calls for persisting and retrieving metadata related to accounts
+ * Handles the calls for persisting and retrieving metadata related to accounts.
*/
public interface AccountMetadataService {
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/token/validators/MTLSCertificateValidatorTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/token/validators/MTLSCertificateValidatorTest.java
index ea516789..b1ec9332 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/token/validators/MTLSCertificateValidatorTest.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/token/validators/MTLSCertificateValidatorTest.java
@@ -39,6 +39,9 @@
import static org.testng.Assert.assertEquals;
+/**
+ * class for MTLSCertificateValidator Test.
+ */
@PrepareForTest({IdentityCommonUtil.class})
@PowerMockIgnore({"jdk.internal.reflect.*"})
public class MTLSCertificateValidatorTest extends PowerMockTestCase {
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/ConsentExtensionDataProvider.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/ConsentExtensionDataProvider.java
index eb9488d9..098a8706 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/ConsentExtensionDataProvider.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/ConsentExtensionDataProvider.java
@@ -17,6 +17,7 @@
*/
package com.wso2.openbanking.accelerator.consent.extensions.authorize.vrp.retrieval.flow;
+import com.wso2.openbanking.accelerator.consent.extensions.utils.ConsentAuthorizeTestConstants;
import org.testng.annotations.DataProvider;
/**
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/VRPConsentRetrievalStepTest.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/VRPConsentRetrievalStepTest.java
index 7637538c..f8b11e02 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/VRPConsentRetrievalStepTest.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/VRPConsentRetrievalStepTest.java
@@ -25,6 +25,7 @@
import com.wso2.openbanking.accelerator.consent.extensions.authorize.model.ConsentData;
import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentExtensionConstants;
import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentServiceUtil;
+import com.wso2.openbanking.accelerator.consent.extensions.utils.ConsentAuthorizeTestConstants;
import com.wso2.openbanking.accelerator.consent.extensions.utils.ConsentExtensionTestUtils;
import com.wso2.openbanking.accelerator.consent.mgt.dao.models.AuthorizationResource;
import com.wso2.openbanking.accelerator.consent.mgt.dao.models.ConsentFile;
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/VRPConsentRetrievalUtilTest.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/VRPConsentRetrievalUtilTest.java
index f17e088d..9ad35bf6 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/VRPConsentRetrievalUtilTest.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/retrieval/flow/VRPConsentRetrievalUtilTest.java
@@ -28,6 +28,7 @@
import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentException;
import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentExtensionConstants;
import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentServiceUtil;
+import com.wso2.openbanking.accelerator.consent.extensions.utils.ConsentAuthorizeTestConstants;
import com.wso2.openbanking.accelerator.consent.extensions.utils.ConsentExtensionTestUtils;
import com.wso2.openbanking.accelerator.consent.mgt.dao.models.AuthorizationResource;
import com.wso2.openbanking.accelerator.consent.mgt.dao.models.ConsentResource;
@@ -53,7 +54,8 @@
import java.util.HashMap;
import java.util.Map;
-import static com.wso2.openbanking.accelerator.consent.extensions.authorize.vrp.retrieval.flow.ConsentAuthorizeTestConstants.VRP_WITHOUT_DATA;
+
+import static com.wso2.openbanking.accelerator.consent.extensions.utils.ConsentAuthorizeTestConstants.VRP_WITHOUT_DATA;
import static org.mockito.Mockito.mock;
import static org.powermock.api.mockito.PowerMockito.doReturn;
import static org.powermock.api.mockito.PowerMockito.when;
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/EventPollingServiceHandler.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/EventPollingServiceHandler.java
index 2c42d2dc..30a02dfe 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/EventPollingServiceHandler.java
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/EventPollingServiceHandler.java
@@ -38,7 +38,7 @@ public interface EventPollingServiceHandler {
EventPollingResponse pollEvents(JSONObject eventPollingRequest);
/**
- * This method is used to map the eventPollingRequest to EventPollingDTO
+ * This method is used to map the eventPollingRequest to EventPollingDTO.
* @param eventPollingRequest JSON request for event polling
* @return eventPollingDTO with the request parameters.
*/
From f1f53540f938aed5bbafa5e7646777f1bad21779 Mon Sep 17 00:00:00 2001
From: kalpana
Date: Wed, 8 May 2024 10:46:19 +0530
Subject: [PATCH 137/281] Resolving the comments
---
.../flow/ConsentPersistStepTests.java | 46 +++++++++++++++++--
.../utils/ConsentAuthorizeTestConstants.java | 17 ++++++-
2 files changed, 57 insertions(+), 6 deletions(-)
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/persistence/flow/ConsentPersistStepTests.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/persistence/flow/ConsentPersistStepTests.java
index 9c6a3212..83232cbd 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/persistence/flow/ConsentPersistStepTests.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/persistence/flow/ConsentPersistStepTests.java
@@ -19,23 +19,28 @@
package com.wso2.openbanking.accelerator.consent.extensions.authorize.vrp.persistence.flow;
import com.wso2.openbanking.accelerator.common.config.OpenBankingConfigParser;
+import com.wso2.openbanking.accelerator.common.exception.ConsentManagementException;
import com.wso2.openbanking.accelerator.common.util.CarbonUtils;
import com.wso2.openbanking.accelerator.consent.extensions.authorize.impl.DefaultConsentPersistStep;
import com.wso2.openbanking.accelerator.consent.extensions.authorize.model.ConsentData;
import com.wso2.openbanking.accelerator.consent.extensions.authorize.model.ConsentPersistData;
import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentException;
import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentServiceUtil;
+import com.wso2.openbanking.accelerator.consent.extensions.internal.ConsentExtensionsDataHolder;
import com.wso2.openbanking.accelerator.consent.extensions.utils.ConsentAuthorizeTestConstants;
import com.wso2.openbanking.accelerator.consent.extensions.utils.ConsentExtensionTestUtils;
import com.wso2.openbanking.accelerator.consent.mgt.dao.models.ConsentResource;
import com.wso2.openbanking.accelerator.consent.mgt.service.impl.ConsentCoreServiceImpl;
import net.minidev.json.JSONObject;
import net.minidev.json.parser.JSONParser;
+import net.minidev.json.parser.ParseException;
import org.mockito.Mock;
+import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.testng.PowerMockObjectFactory;
import org.testng.IObjectFactory;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
@@ -45,8 +50,7 @@
import java.util.HashMap;
import java.util.Map;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.*;
import static org.powermock.api.mockito.PowerMockito.when;
/**
@@ -67,6 +71,9 @@ public class ConsentPersistStepTests {
private static ConsentData consentDataMock;
@Mock
private static ConsentResource consentResourceMock;
+ @Mock
+ private ConsentExtensionsDataHolder consentExtensionsDataHolderMock;
+
@Mock
ConsentCoreServiceImpl consentCoreServiceMock;
private static Map configMap;
@@ -83,6 +90,8 @@ public void initTest() throws ReflectiveOperationException {
consentResourceMock = mock(ConsentResource.class);
consentCoreServiceMock = mock(ConsentCoreServiceImpl.class);
+ consentExtensionsDataHolderMock = mock(ConsentExtensionsDataHolder.class);
+
configMap = new HashMap<>();
configMap.put("ErrorURL", "https://localhost:8243/error");
@@ -96,7 +105,7 @@ public void initTest() throws ReflectiveOperationException {
@ObjectFactory
public IObjectFactory getObjectFactory() {
- return new org.powermock.modules.testng.PowerMockObjectFactory();
+ return new PowerMockObjectFactory();
}
@BeforeMethod
@@ -224,6 +233,35 @@ public void testCOFPersistThrowingExceptionWhenConsentBinding() throws Exception
doReturn(payload).when(consentPersistDataMock).getPayload();
consentPersistStep.execute(consentPersistDataMock);
- }
+}
+ @Test
+ public void testAccountConsentPersistSuccessScenarioWithApprovalTrue()
+ throws ParseException, ConsentManagementException {
+
+ Mockito.doReturn(consentDataMock).when(consentPersistDataMock).getConsentData();
+ Mockito.doReturn(ConsentAuthorizeTestConstants.CONSENT_ID).when(consentDataMock).getConsentId();
+ Mockito.doReturn(ConsentAuthorizeTestConstants.USER_ID).when(consentDataMock).getUserId();
+ Mockito.doReturn(ConsentAuthorizeTestConstants.CLIENT_ID).when(consentDataMock).getClientId();
+ Mockito.doReturn(consentResourceMock).when(consentDataMock).getConsentResource();
+ Mockito.doReturn(ConsentAuthorizeTestConstants.getAuthResource()).when(consentDataMock).getAuthResource();
+ Mockito.doReturn(ConsentAuthorizeTestConstants.ACCOUNTS).when(consentResourceMock).getConsentType();
+ Mockito.doReturn(true).when(consentPersistDataMock).getApproval();
+
+ Mockito.doReturn(true).when(consentCoreServiceMock).bindUserAccountsToConsent(
+ Mockito.anyObject(), Mockito.anyString(), Mockito.anyString(), Mockito.anyMap(),
+ Mockito.anyString(), Mockito.anyString());
+
+ PowerMockito.mockStatic(ConsentServiceUtil.class);
+ PowerMockito.when(ConsentServiceUtil.getConsentService()).thenReturn(consentCoreServiceMock);
+
+ JSONObject payload = (JSONObject) parser.parse(ConsentAuthorizeTestConstants.ACCOUNT_PERSIST_PAYLOAD);
+ Mockito.doReturn(payload).when(consentPersistDataMock).getPayload();
+
+ consentPersistStep.execute(consentPersistDataMock);
+ }
}
+
+
+
+
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/utils/ConsentAuthorizeTestConstants.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/utils/ConsentAuthorizeTestConstants.java
index da81bb5f..71bac8ce 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/utils/ConsentAuthorizeTestConstants.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/utils/ConsentAuthorizeTestConstants.java
@@ -349,9 +349,7 @@ public class ConsentAuthorizeTestConstants {
" \"approval\":\"true\"," +
" \"cofAccount\":\"1234\"," +
" \"accountIds\": \"\"," +
- " \"isReauthorization\":\"false\"," +
" \"type\":\"accounts\"," +
- " \"paymentAccount\":\"\"" +
"}";
public static final String COF_PERSIST_PAYLOAD_WITHOUT_COF_ACC = " " +
@@ -389,4 +387,19 @@ public static AuthorizationResource getAuthResource() {
return authorizationResource;
}
+
+ public static final String ACCOUNT_PERSIST_PAYLOAD = " " +
+ "{" +
+ " \"metadata\": {" +
+ " \"commonAuthId\":\"b37b9c9b-b5ce-4889-966e-9cb30f70cc78\"" +
+ " }," +
+ " \"cofAccount\":\"\"," +
+ " \"approval\":\"true\"," +
+ " \"accountIds\":[" +
+ " \"30080012343456\"" +
+ " ]," +
+ " \"type\":\"accounts\"," +
+ " \"paymentAccount\":\"\"" +
+ "}";
+
}
From b6f317b64123a62d6d1b5e8f2ed49bd4dfd1bcb1 Mon Sep 17 00:00:00 2001
From: kalpana
Date: Wed, 8 May 2024 11:22:41 +0530
Subject: [PATCH 138/281] Resolving the comments
---
.../common/util/ErrorConstants.java | 9 +++------
.../impl/VRPSubmissionPayloadValidator.java | 19 +++++++++++--------
2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java
index 7238340c..c28a6c46 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java
@@ -289,10 +289,7 @@ public class ErrorConstants {
public static final String NOT_STRING_ERROR = "Parameter amount or currency is not a String";
// VRP Submission flow
- public static final String PAYLOAD_FORMAT_ERROR_SUBMISSION = "Missing mandatory parameter Initiation" +
- " in the payload";
- public static final String REMITTANCE_INFO_NOT_FOUND = "Remittance ifo isn't present in the request.";
- public static final String PATH_REMITTANCE_INFO = "Data.Initiation.RemittanceInformation";
+ public static final String REMITTANCE_INFO_NOT_FOUND = "Remittance info is not present in the request.";
public static final String INSTRUCTION_IDENTIFICATION_NOT_FOUND = "Instruction Identification isn't present" +
" in the request";
public static final String END_TO_END_IDENTIFICATION_PARAMETER_NOT_FOUND = "End to End Identification isn't" +
@@ -321,9 +318,9 @@ public class ErrorConstants {
" isn't present in the correct JSON format in the request.";
public static final String DEBTOR_ACC_NOT_JSON_ERROR = "Debtor Account isn't present in the correct JSON format " +
"in the request.";
- public static final String INITIATION_REMITTANCE_INFO_NOT_JSON_ERROR = "Remittance info of initiation isn't " +
+ public static final String INITIATION_REMITTANCE_INFO_NOT_JSON_ERROR = "Remittance info of initiation is not " +
"present in the correct JSON format in the request.";
- public static final String INSTRUCTION_REMITTANCE_INFO_NOT_JSON_ERROR = "Remittance info of instruction isn't" +
+ public static final String INSTRUCTION_REMITTANCE_INFO_NOT_JSON_ERROR = "Remittance info of instruction is not" +
" present in the correct JSON format in the request.";
}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/VRPSubmissionPayloadValidator.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/VRPSubmissionPayloadValidator.java
index 9b6105d0..01645f05 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/VRPSubmissionPayloadValidator.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/VRPSubmissionPayloadValidator.java
@@ -59,7 +59,8 @@ public static JSONObject validateInitiation(JSONObject initiationOfSubmission,
Object consentInitiationCreditorAccounts = initiationParameterOfConsentInitiation.
get(ConsentExtensionConstants.CREDITOR_ACC);
- if (areJSONObjects(submissionCreditorAccounts, consentInitiationCreditorAccounts)) {
+ if (submissionCreditorAccounts instanceof JSONObject &&
+ consentInitiationCreditorAccounts instanceof JSONObject) {
JSONObject submissionCreditorAccount = (JSONObject) initiationOfSubmission.
get(ConsentExtensionConstants.CREDITOR_ACC);
JSONObject consentInitiationCreditorAccount = (JSONObject)
@@ -96,7 +97,8 @@ public static JSONObject validateInitiation(JSONObject initiationOfSubmission,
Object consentInitiationDebtorAccounts = initiationParameterOfConsentInitiation
.get(ConsentExtensionConstants.DEBTOR_ACC);
- if (areJSONObjects(submissionDebtorAccounts, consentInitiationDebtorAccounts)) {
+ if (submissionDebtorAccounts instanceof JSONObject &&
+ consentInitiationDebtorAccounts instanceof JSONObject) {
JSONObject submissionDebtorAccount = (JSONObject) initiationOfSubmission
.get(ConsentExtensionConstants.DEBTOR_ACC);
JSONObject consentInitiationDebtorAccount = (JSONObject) initiationParameterOfConsentInitiation
@@ -122,7 +124,8 @@ public static JSONObject validateInitiation(JSONObject initiationOfSubmission,
Object remittanceInformationInitiation = initiationParameterOfConsentInitiation
.get(ConsentExtensionConstants.REMITTANCE_INFO);
- if (areJSONObjects(remittanceInformationSubmission, remittanceInformationInitiation)) {
+ if (remittanceInformationSubmission instanceof JSONObject &&
+ remittanceInformationInitiation instanceof JSONObject) {
JSONObject remittanceInformationSub = (JSONObject) initiationOfSubmission
.get(ConsentExtensionConstants.REMITTANCE_INFO);
JSONObject remittanceInformationInit = (JSONObject) initiationParameterOfConsentInitiation
@@ -172,7 +175,6 @@ public static JSONObject validateInstruction(JSONObject submission,
ErrorConstants.INVALID_SUBMISSION_TYPE);
}
} else {
- //log.error(ErrorConstants.INSTRUCTION_IDENTIFICATION_NOT_FOUND);
return ConsentValidatorUtil.getValidationResult(ErrorConstants.FIELD_MISSING,
ErrorConstants.INSTRUCTION_IDENTIFICATION_NOT_FOUND);
}
@@ -180,7 +182,6 @@ public static JSONObject validateInstruction(JSONObject submission,
if (submission.containsKey(ConsentExtensionConstants.END_TO_END_IDENTIFICATION)) {
Object value = submission.get(ConsentExtensionConstants.END_TO_END_IDENTIFICATION);
if (!(value instanceof String)) {
- // log.error(ErrorConstants.INVALID_TYPE);
return ConsentValidatorUtil.getValidationResult(ErrorConstants.FIELD_MISSING,
ErrorConstants.INVALID_TYPE);
}
@@ -196,7 +197,8 @@ public static JSONObject validateInstruction(JSONObject submission,
Object submissionCreditorAccounts = submission.get(ConsentExtensionConstants.CREDITOR_ACC);
Object consentInitiationCreditorAccounts = initiation.get(ConsentExtensionConstants.CREDITOR_ACC);
- if (areJSONObjects(submissionCreditorAccounts, consentInitiationCreditorAccounts)) {
+ if (submissionCreditorAccounts instanceof JSONObject &&
+ consentInitiationCreditorAccounts instanceof JSONObject) {
JSONObject submissionCreditorAccount = (JSONObject) submission.
get(ConsentExtensionConstants.CREDITOR_ACC);
JSONObject consentInitiationCreditorAccount = (JSONObject) initiation.
@@ -228,7 +230,8 @@ public static JSONObject validateInstruction(JSONObject submission,
Object remittanceInformationSubmission = submission.get(ConsentExtensionConstants.REMITTANCE_INFO);
Object remittanceInformationInitiation = initiation.get(ConsentExtensionConstants.REMITTANCE_INFO);
- if (areJSONObjects(remittanceInformationSubmission, remittanceInformationInitiation)) {
+ if (remittanceInformationSubmission instanceof JSONObject &&
+ remittanceInformationInitiation instanceof JSONObject) {
JSONObject remittanceInformationSub = (JSONObject) submission
.get(ConsentExtensionConstants.REMITTANCE_INFO);
JSONObject remittanceInformationInit = (JSONObject) initiation
@@ -319,7 +322,7 @@ public static JSONObject validateRisk(JSONObject riskOfSubmission,
@param obj2 The second object to compare.
@return true if both objects are instances of JSONObject, false otherwise.
*/
- public static boolean areJSONObjects(Object obj1, Object obj2) {
+ public static boolean areJSONObjects(Object obj1 , Object obj2) {
return (obj1 instanceof JSONObject) && (obj2 instanceof JSONObject);
}
From e1e94dbb0ca2c6d0110d6a290a56e1bdb902bafa Mon Sep 17 00:00:00 2001
From: kalpana
Date: Wed, 8 May 2024 12:34:03 +0530
Subject: [PATCH 139/281] Resolving the comments
---
.../flow/ConsentPersistStepTests.java | 165 +++++++++---------
1 file changed, 78 insertions(+), 87 deletions(-)
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/persistence/flow/ConsentPersistStepTests.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/persistence/flow/ConsentPersistStepTests.java
index 83232cbd..db75703c 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/persistence/flow/ConsentPersistStepTests.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/authorize/vrp/persistence/flow/ConsentPersistStepTests.java
@@ -19,21 +19,18 @@
package com.wso2.openbanking.accelerator.consent.extensions.authorize.vrp.persistence.flow;
import com.wso2.openbanking.accelerator.common.config.OpenBankingConfigParser;
-import com.wso2.openbanking.accelerator.common.exception.ConsentManagementException;
import com.wso2.openbanking.accelerator.common.util.CarbonUtils;
import com.wso2.openbanking.accelerator.consent.extensions.authorize.impl.DefaultConsentPersistStep;
import com.wso2.openbanking.accelerator.consent.extensions.authorize.model.ConsentData;
import com.wso2.openbanking.accelerator.consent.extensions.authorize.model.ConsentPersistData;
import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentException;
import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentServiceUtil;
-import com.wso2.openbanking.accelerator.consent.extensions.internal.ConsentExtensionsDataHolder;
import com.wso2.openbanking.accelerator.consent.extensions.utils.ConsentAuthorizeTestConstants;
import com.wso2.openbanking.accelerator.consent.extensions.utils.ConsentExtensionTestUtils;
import com.wso2.openbanking.accelerator.consent.mgt.dao.models.ConsentResource;
import com.wso2.openbanking.accelerator.consent.mgt.service.impl.ConsentCoreServiceImpl;
import net.minidev.json.JSONObject;
import net.minidev.json.parser.JSONParser;
-import net.minidev.json.parser.ParseException;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
@@ -50,7 +47,6 @@
import java.util.HashMap;
import java.util.Map;
-import static org.mockito.Mockito.*;
import static org.powermock.api.mockito.PowerMockito.when;
/**
@@ -71,9 +67,6 @@ public class ConsentPersistStepTests {
private static ConsentData consentDataMock;
@Mock
private static ConsentResource consentResourceMock;
- @Mock
- private ConsentExtensionsDataHolder consentExtensionsDataHolderMock;
-
@Mock
ConsentCoreServiceImpl consentCoreServiceMock;
private static Map configMap;
@@ -85,12 +78,10 @@ public void initTest() throws ReflectiveOperationException {
MockitoAnnotations.initMocks(this);
consentPersistStep = new DefaultConsentPersistStep();
- consentPersistDataMock = mock(ConsentPersistData.class);
- consentDataMock = mock(ConsentData.class);
- consentResourceMock = mock(ConsentResource.class);
- consentCoreServiceMock = mock(ConsentCoreServiceImpl.class);
-
- consentExtensionsDataHolderMock = mock(ConsentExtensionsDataHolder.class);
+ consentPersistDataMock = Mockito.mock(ConsentPersistData.class);
+ consentDataMock = Mockito.mock(ConsentData.class);
+ consentResourceMock = Mockito.mock(ConsentResource.class);
+ consentCoreServiceMock = Mockito.mock(ConsentCoreServiceImpl.class);
configMap = new HashMap<>();
configMap.put("ErrorURL", "https://localhost:8243/error");
@@ -111,7 +102,7 @@ public IObjectFactory getObjectFactory() {
@BeforeMethod
public void initMethod() {
- openBankingConfigParserMock = mock(OpenBankingConfigParser.class);
+ openBankingConfigParserMock = Mockito.mock(OpenBankingConfigParser.class);
PowerMockito.mockStatic(OpenBankingConfigParser.class);
when(OpenBankingConfigParser.getInstance()).thenReturn(openBankingConfigParserMock);
@@ -123,16 +114,16 @@ public void initMethod() {
@Test(priority = 1, expectedExceptions = ConsentException.class)
public void testConsentPersistWithoutConsentId() {
- doReturn(consentDataMock).when(consentPersistDataMock).getConsentData();
+ Mockito.doReturn(consentDataMock).when(consentPersistDataMock).getConsentData();
consentPersistStep.execute(consentPersistDataMock);
}
@Test(priority = 3, expectedExceptions = ConsentException.class)
public void testConsentPersistWithoutAuthResource() {
- doReturn(consentDataMock).when(consentPersistDataMock).getConsentData();
- doReturn("1234").when(consentDataMock).getConsentId();
- doReturn(consentResourceMock).when(consentDataMock).getConsentResource();
+ Mockito.doReturn(consentDataMock).when(consentPersistDataMock).getConsentData();
+ Mockito.doReturn("1234").when(consentDataMock).getConsentId();
+ Mockito.doReturn(consentResourceMock).when(consentDataMock).getConsentResource();
consentPersistStep.execute(consentPersistDataMock);
}
@@ -140,18 +131,18 @@ public void testConsentPersistWithoutAuthResource() {
@Test(priority = 6, expectedExceptions = ConsentException.class)
public void testAccountConsentPersistWithoutAccountIDs() throws Exception {
- doReturn(consentDataMock).when(consentPersistDataMock).getConsentData();
- doReturn(ConsentAuthorizeTestConstants.CONSENT_ID).when(consentDataMock).getConsentId();
- doReturn(ConsentAuthorizeTestConstants.USER_ID).when(consentDataMock).getUserId();
- doReturn(ConsentAuthorizeTestConstants.CLIENT_ID).when(consentDataMock).getClientId();
- doReturn(consentResourceMock).when(consentDataMock).getConsentResource();
- doReturn(ConsentAuthorizeTestConstants.getAuthResource()).when(consentDataMock).getAuthResource();
- doReturn(ConsentAuthorizeTestConstants.ACCOUNTS).when(consentResourceMock).getConsentType();
- doReturn(true).when(consentPersistDataMock).getApproval();
+ Mockito.doReturn(consentDataMock).when(consentPersistDataMock).getConsentData();
+ Mockito.doReturn(ConsentAuthorizeTestConstants.CONSENT_ID).when(consentDataMock).getConsentId();
+ Mockito.doReturn(ConsentAuthorizeTestConstants.USER_ID).when(consentDataMock).getUserId();
+ Mockito.doReturn(ConsentAuthorizeTestConstants.CLIENT_ID).when(consentDataMock).getClientId();
+ Mockito.doReturn(consentResourceMock).when(consentDataMock).getConsentResource();
+ Mockito.doReturn(ConsentAuthorizeTestConstants.getAuthResource()).when(consentDataMock).getAuthResource();
+ Mockito.doReturn(ConsentAuthorizeTestConstants.ACCOUNTS).when(consentResourceMock).getConsentType();
+ Mockito.doReturn(true).when(consentPersistDataMock).getApproval();
JSONObject payload = (JSONObject) parser
.parse(ConsentAuthorizeTestConstants.ACCOUNT_PERSIST_PAYLOAD_WITHOUT_ACCOUNT_ID);
- doReturn(payload).when(consentPersistDataMock).getPayload();
+ Mockito.doReturn(payload).when(consentPersistDataMock).getPayload();
consentPersistStep.execute(consentPersistDataMock);
}
@@ -159,18 +150,18 @@ public void testAccountConsentPersistWithoutAccountIDs() throws Exception {
@Test(priority = 7, expectedExceptions = ConsentException.class)
public void testAccountConsentPersistWithNonStringAccountIDs() throws Exception {
- doReturn(consentDataMock).when(consentPersistDataMock).getConsentData();
- doReturn(ConsentAuthorizeTestConstants.CONSENT_ID).when(consentDataMock).getConsentId();
- doReturn(ConsentAuthorizeTestConstants.USER_ID).when(consentDataMock).getUserId();
- doReturn(ConsentAuthorizeTestConstants.CLIENT_ID).when(consentDataMock).getClientId();
- doReturn(consentResourceMock).when(consentDataMock).getConsentResource();
- doReturn(ConsentAuthorizeTestConstants.getAuthResource()).when(consentDataMock).getAuthResource();
- doReturn(ConsentAuthorizeTestConstants.ACCOUNTS).when(consentResourceMock).getConsentType();
- doReturn(true).when(consentPersistDataMock).getApproval();
+ Mockito.doReturn(consentDataMock).when(consentPersistDataMock).getConsentData();
+ Mockito.doReturn(ConsentAuthorizeTestConstants.CONSENT_ID).when(consentDataMock).getConsentId();
+ Mockito.doReturn(ConsentAuthorizeTestConstants.USER_ID).when(consentDataMock).getUserId();
+ Mockito.doReturn(ConsentAuthorizeTestConstants.CLIENT_ID).when(consentDataMock).getClientId();
+ Mockito.doReturn(consentResourceMock).when(consentDataMock).getConsentResource();
+ Mockito.doReturn(ConsentAuthorizeTestConstants.getAuthResource()).when(consentDataMock).getAuthResource();
+ Mockito.doReturn(ConsentAuthorizeTestConstants.ACCOUNTS).when(consentResourceMock).getConsentType();
+ Mockito.doReturn(true).when(consentPersistDataMock).getApproval();
JSONObject payload = (JSONObject) parser
.parse(ConsentAuthorizeTestConstants.PAYLOAD_WITH_NON_STRING_ACCOUNTID);
- doReturn(payload).when(consentPersistDataMock).getPayload();
+ Mockito.doReturn(payload).when(consentPersistDataMock).getPayload();
consentPersistStep.execute(consentPersistDataMock);
}
@@ -178,19 +169,19 @@ public void testAccountConsentPersistWithNonStringAccountIDs() throws Exception
@Test(priority = 9, expectedExceptions = ConsentException.class)
public void testCOFConsentPersistWithoutCOFAccount() throws Exception {
- doReturn(consentDataMock).when(consentPersistDataMock).getConsentData();
- doReturn(ConsentAuthorizeTestConstants.CONSENT_ID).when(consentDataMock).getConsentId();
- doReturn(ConsentAuthorizeTestConstants.USER_ID).when(consentDataMock).getUserId();
- doReturn(ConsentAuthorizeTestConstants.CLIENT_ID).when(consentDataMock).getClientId();
- doReturn(consentResourceMock).when(consentDataMock).getConsentResource();
- doReturn(ConsentAuthorizeTestConstants.getAuthResource()).when(consentDataMock).getAuthResource();
- doReturn(ConsentAuthorizeTestConstants.FUNDS_CONFIRMATIONS).when(consentResourceMock)
+ Mockito.doReturn(consentDataMock).when(consentPersistDataMock).getConsentData();
+ Mockito.doReturn(ConsentAuthorizeTestConstants.CONSENT_ID).when(consentDataMock).getConsentId();
+ Mockito.doReturn(ConsentAuthorizeTestConstants.USER_ID).when(consentDataMock).getUserId();
+ Mockito.doReturn(ConsentAuthorizeTestConstants.CLIENT_ID).when(consentDataMock).getClientId();
+ Mockito.doReturn(consentResourceMock).when(consentDataMock).getConsentResource();
+ Mockito.doReturn(ConsentAuthorizeTestConstants.getAuthResource()).when(consentDataMock).getAuthResource();
+ Mockito.doReturn(ConsentAuthorizeTestConstants.FUNDS_CONFIRMATIONS).when(consentResourceMock)
.getConsentType();
- doReturn(true).when(consentPersistDataMock).getApproval();
+ Mockito.doReturn(true).when(consentPersistDataMock).getApproval();
JSONObject payload = (JSONObject) parser
.parse(ConsentAuthorizeTestConstants.COF_PERSIST_PAYLOAD_WITHOUT_COF_ACC);
- doReturn(payload).when(consentPersistDataMock).getPayload();
+ Mockito.doReturn(payload).when(consentPersistDataMock).getPayload();
consentPersistStep.execute(consentPersistDataMock);
}
@@ -198,19 +189,19 @@ public void testCOFConsentPersistWithoutCOFAccount() throws Exception {
@Test(priority = 10, expectedExceptions = ConsentException.class)
public void testCOFConsentPersistWithNonStringCOFAccount() throws Exception {
- doReturn(consentDataMock).when(consentPersistDataMock).getConsentData();
- doReturn(ConsentAuthorizeTestConstants.CONSENT_ID).when(consentDataMock).getConsentId();
- doReturn(ConsentAuthorizeTestConstants.USER_ID).when(consentDataMock).getUserId();
- doReturn(ConsentAuthorizeTestConstants.CLIENT_ID).when(consentDataMock).getClientId();
- doReturn(consentResourceMock).when(consentDataMock).getConsentResource();
- doReturn(ConsentAuthorizeTestConstants.getAuthResource()).when(consentDataMock).getAuthResource();
- doReturn(ConsentAuthorizeTestConstants.FUNDS_CONFIRMATIONS).when(consentResourceMock)
+ Mockito.doReturn(consentDataMock).when(consentPersistDataMock).getConsentData();
+ Mockito.doReturn(ConsentAuthorizeTestConstants.CONSENT_ID).when(consentDataMock).getConsentId();
+ Mockito.doReturn(ConsentAuthorizeTestConstants.USER_ID).when(consentDataMock).getUserId();
+ Mockito.doReturn(ConsentAuthorizeTestConstants.CLIENT_ID).when(consentDataMock).getClientId();
+ Mockito.doReturn(consentResourceMock).when(consentDataMock).getConsentResource();
+ Mockito.doReturn(ConsentAuthorizeTestConstants.getAuthResource()).when(consentDataMock).getAuthResource();
+ Mockito.doReturn(ConsentAuthorizeTestConstants.FUNDS_CONFIRMATIONS).when(consentResourceMock)
.getConsentType();
- doReturn(true).when(consentPersistDataMock).getApproval();
+ Mockito.doReturn(true).when(consentPersistDataMock).getApproval();
JSONObject payload = (JSONObject) parser
.parse(ConsentAuthorizeTestConstants.COF_PERSIST_PAYLOAD_WITH_NON_STRING_COF_ACC);
- doReturn(payload).when(consentPersistDataMock).getPayload();
+ Mockito.doReturn(payload).when(consentPersistDataMock).getPayload();
consentPersistStep.execute(consentPersistDataMock);
}
@@ -218,48 +209,48 @@ public void testCOFConsentPersistWithNonStringCOFAccount() throws Exception {
@Test(priority = 11, expectedExceptions = ConsentException.class)
public void testCOFPersistThrowingExceptionWhenConsentBinding() throws Exception {
- doReturn(consentDataMock).when(consentPersistDataMock).getConsentData();
- doReturn(ConsentAuthorizeTestConstants.CONSENT_ID).when(consentDataMock).getConsentId();
- doReturn(ConsentAuthorizeTestConstants.USER_ID).when(consentDataMock).getUserId();
- doReturn(ConsentAuthorizeTestConstants.CLIENT_ID).when(consentDataMock).getClientId();
- doReturn(consentResourceMock).when(consentDataMock).getConsentResource();
- doReturn(ConsentAuthorizeTestConstants.getAuthResource()).when(consentDataMock).getAuthResource();
- doReturn(ConsentAuthorizeTestConstants.FUNDS_CONFIRMATIONS).when(consentResourceMock)
- .getConsentType();
- doReturn(false).when(consentPersistDataMock).getApproval();
- JSONParser parser = new JSONParser(JSONParser.MODE_PERMISSIVE);
- JSONObject payload = (JSONObject) parser
- .parse(ConsentAuthorizeTestConstants.COF_PERSIST_PAYLOAD);
- doReturn(payload).when(consentPersistDataMock).getPayload();
-
- consentPersistStep.execute(consentPersistDataMock);
-}
-
- @Test
- public void testAccountConsentPersistSuccessScenarioWithApprovalTrue()
- throws ParseException, ConsentManagementException {
-
Mockito.doReturn(consentDataMock).when(consentPersistDataMock).getConsentData();
Mockito.doReturn(ConsentAuthorizeTestConstants.CONSENT_ID).when(consentDataMock).getConsentId();
Mockito.doReturn(ConsentAuthorizeTestConstants.USER_ID).when(consentDataMock).getUserId();
Mockito.doReturn(ConsentAuthorizeTestConstants.CLIENT_ID).when(consentDataMock).getClientId();
Mockito.doReturn(consentResourceMock).when(consentDataMock).getConsentResource();
Mockito.doReturn(ConsentAuthorizeTestConstants.getAuthResource()).when(consentDataMock).getAuthResource();
- Mockito.doReturn(ConsentAuthorizeTestConstants.ACCOUNTS).when(consentResourceMock).getConsentType();
- Mockito.doReturn(true).when(consentPersistDataMock).getApproval();
-
- Mockito.doReturn(true).when(consentCoreServiceMock).bindUserAccountsToConsent(
- Mockito.anyObject(), Mockito.anyString(), Mockito.anyString(), Mockito.anyMap(),
- Mockito.anyString(), Mockito.anyString());
-
- PowerMockito.mockStatic(ConsentServiceUtil.class);
- PowerMockito.when(ConsentServiceUtil.getConsentService()).thenReturn(consentCoreServiceMock);
-
- JSONObject payload = (JSONObject) parser.parse(ConsentAuthorizeTestConstants.ACCOUNT_PERSIST_PAYLOAD);
+ Mockito.doReturn(ConsentAuthorizeTestConstants.FUNDS_CONFIRMATIONS).when(consentResourceMock)
+ .getConsentType();
+ Mockito.doReturn(false).when(consentPersistDataMock).getApproval();
+ JSONParser parser = new JSONParser(JSONParser.MODE_PERMISSIVE);
+ JSONObject payload = (JSONObject) parser
+ .parse(ConsentAuthorizeTestConstants.COF_PERSIST_PAYLOAD);
Mockito.doReturn(payload).when(consentPersistDataMock).getPayload();
consentPersistStep.execute(consentPersistDataMock);
- }
+}
+
+// @Test
+// public void testAccountConsentPersistSuccessScenarioWithApprovalTrue()
+// throws ParseException, ConsentManagementException {
+//
+// Mockito.doReturn(consentDataMock).when(consentPersistDataMock).getConsentData();
+// Mockito.doReturn(ConsentAuthorizeTestConstants.CONSENT_ID).when(consentDataMock).getConsentId();
+// Mockito.doReturn(ConsentAuthorizeTestConstants.USER_ID).when(consentDataMock).getUserId();
+// Mockito.doReturn(ConsentAuthorizeTestConstants.CLIENT_ID).when(consentDataMock).getClientId();
+// Mockito.doReturn(consentResourceMock).when(consentDataMock).getConsentResource();
+// Mockito.doReturn(ConsentAuthorizeTestConstants.getAuthResource()).when(consentDataMock).getAuthResource();
+// Mockito.doReturn(ConsentAuthorizeTestConstants.ACCOUNTS).when(consentResourceMock).getConsentType();
+// Mockito.doReturn(true).when(consentPersistDataMock).getApproval();
+//
+// Mockito.doReturn(true).when(consentCoreServiceMock).bindUserAccountsToConsent(
+// Mockito.anyObject(), Mockito.anyString(), Mockito.anyString(), Mockito.anyMap(),
+// Mockito.anyString(), Mockito.anyString());
+//
+// PowerMockito.mockStatic(ConsentServiceUtil.class);
+// PowerMockito.when(ConsentServiceUtil.getConsentService()).thenReturn(consentCoreServiceMock);
+//
+// JSONObject payload = (JSONObject) parser.parse(ConsentAuthorizeTestConstants.ACCOUNT_PERSIST_PAYLOAD);
+// Mockito.doReturn(payload).when(consentPersistDataMock).getPayload();
+//
+// consentPersistStep.execute(consentPersistDataMock);
+// }
}
From e711dc65ac136e76659a4926b0ca698068cf28ad Mon Sep 17 00:00:00 2001
From: WSO2 Builder
Date: Wed, 8 May 2024 08:49:09 +0000
Subject: [PATCH 140/281] [WSO2 Release] [Jenkins #278] [Release 3.2.4] prepare
release v3.2.4
---
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.common/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.data.publisher/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.gateway/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.identity/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.keymanager/pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.runtime/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.throttler.dao/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.consent.endpoint/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.demo.backend/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.authentication.webapp/pom.xml | 2 +-
open-banking-accelerator/pom.xml | 4 ++--
pom.xml | 4 ++--
react-apps/pom.xml | 2 +-
react-apps/self-care-portal/pom.xml | 2 +-
29 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml b/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml
index 2e74f29c..e2007abb 100644
--- a/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml
+++ b/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml
@@ -19,7 +19,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4-SNAPSHOT
+ 3.2.4../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
index eb689092..d61f833a 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4-SNAPSHOT
+ 3.2.4../../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml
index c28c4655..66d9d9d2 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml
@@ -23,7 +23,7 @@
com.wso2.openbanking.accelerator.data.publishercom.wso2.openbanking.accelerator
- 3.2.4-SNAPSHOT
+ 3.2.4../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
index c5e53ad3..1a7b805c 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4-SNAPSHOT
+ 3.2.4../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml
index 9fdb5738..dc4ef32f 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4-SNAPSHOT
+ 3.2.4../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
index 5d0fe88e..b216b5bc 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4-SNAPSHOT
+ 3.2.4../../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml
index a5ac6829..c0cb671d 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4-SNAPSHOT
+ 3.2.4../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml
index b924760f..0881e3a1 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml
@@ -18,7 +18,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4-SNAPSHOT
+ 3.2.4../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml
index 99262a60..a4d0e9d6 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml
@@ -20,7 +20,7 @@
com.wso2.openbanking.accelerator.runtimecom.wso2.openbanking.accelerator
- 3.2.4-SNAPSHOT
+ 3.2.4../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml
index 8c779fb7..5fa59b91 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4-SNAPSHOT
+ 3.2.4../../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml
index 53c76ed7..2ed5626e 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4-SNAPSHOT
+ 3.2.4../../pom.xml
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml
index 45b4514b..d5687212 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4-SNAPSHOT
+ 3.2.4../../../pom.xml
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
index 6b087782..ffdc18fa 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4-SNAPSHOT
+ 3.2.4../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml
index c228a287..60533b24 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml
@@ -21,7 +21,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4-SNAPSHOT
+ 3.2.4../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml
index dac6381b..f802b1fd 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml
@@ -19,7 +19,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4-SNAPSHOT
+ 3.2.4../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml
index 65cccb6c..96ee9fa5 100644
--- a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml
+++ b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4-SNAPSHOT
+ 3.2.4../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml
index e690e52d..7ce0d757 100644
--- a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml
+++ b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4-SNAPSHOT
+ 3.2.4../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml
index f8483079..cfd9a53a 100755
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml
@@ -21,7 +21,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4-SNAPSHOT
+ 3.2.4../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml
index 3a28f7bc..69e51a6d 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml
@@ -18,7 +18,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4-SNAPSHOT
+ 3.2.4../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml
index 0b131351..08166b2d 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4-SNAPSHOT
+ 3.2.4../../../pom.xml
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
index 067eadc7..4ca45216 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4-SNAPSHOT
+ 3.2.4../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml
index 5c83936c..9f2fcfb2 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml
@@ -21,7 +21,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4-SNAPSHOT
+ 3.2.4../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml
index 0dc31114..e25f9af2 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml
@@ -19,7 +19,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4-SNAPSHOT
+ 3.2.4../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml
index c1627fd2..90f9af39 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4-SNAPSHOT
+ 3.2.4../../../pom.xml
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml
index de100d98..f8fbaa2e 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml
@@ -21,7 +21,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4-SNAPSHOT
+ 3.2.4../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/pom.xml b/open-banking-accelerator/pom.xml
index a74277b2..e5b7e563 100644
--- a/open-banking-accelerator/pom.xml
+++ b/open-banking-accelerator/pom.xml
@@ -23,14 +23,14 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.2.4-SNAPSHOT
+ 3.2.4../pom.xmlWSO2 Open Banking Acceleratoropen-banking-acceleratorpom
- 3.2.4-SNAPSHOT
+ 3.2.4components/com.wso2.openbanking.accelerator.common
diff --git a/pom.xml b/pom.xml
index c00f9acc..26895155 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,7 +21,7 @@
com.wso2.openbanking.acceleratoropen-bankingpom
- 3.2.4-SNAPSHOT
+ 3.2.4org.wso2
@@ -172,7 +172,7 @@
https://github.com/wso2/financial-open-banking.gitscm:git:https://github.com/wso2/financial-open-banking.gitscm:git:https://github.com/wso2/financial-open-banking.git
- HEAD
+ v3.2.4
diff --git a/react-apps/pom.xml b/react-apps/pom.xml
index 5520caef..fb824fe0 100644
--- a/react-apps/pom.xml
+++ b/react-apps/pom.xml
@@ -23,7 +23,7 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.2.4-SNAPSHOT
+ 3.2.4../pom.xml
diff --git a/react-apps/self-care-portal/pom.xml b/react-apps/self-care-portal/pom.xml
index be86ad9a..4eb2c523 100644
--- a/react-apps/self-care-portal/pom.xml
+++ b/react-apps/self-care-portal/pom.xml
@@ -23,7 +23,7 @@
com.wso2.openbanking.acceleratorreact-apps
- 3.2.4-SNAPSHOT
+ 3.2.4../pom.xml
From e874db6724476323069ec17437cfca26dfc8ae06 Mon Sep 17 00:00:00 2001
From: WSO2 Builder
Date: Wed, 8 May 2024 08:49:11 +0000
Subject: [PATCH 141/281] [WSO2 Release] [Jenkins #278] [Release 3.2.4] prepare
for next development iteration
---
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.common/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.data.publisher/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.gateway/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.identity/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.keymanager/pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.runtime/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.throttler.dao/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.consent.endpoint/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.demo.backend/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.authentication.webapp/pom.xml | 2 +-
open-banking-accelerator/pom.xml | 4 ++--
pom.xml | 4 ++--
react-apps/pom.xml | 2 +-
react-apps/self-care-portal/pom.xml | 2 +-
29 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml b/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml
index e2007abb..47061554 100644
--- a/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml
+++ b/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml
@@ -19,7 +19,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4
+ 3.2.5-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
index d61f833a..90001315 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4
+ 3.2.5-SNAPSHOT../../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml
index 66d9d9d2..afc3d91d 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml
@@ -23,7 +23,7 @@
com.wso2.openbanking.accelerator.data.publishercom.wso2.openbanking.accelerator
- 3.2.4
+ 3.2.5-SNAPSHOT../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
index 1a7b805c..1c996cd8 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4
+ 3.2.5-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml
index dc4ef32f..31c817f4 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4
+ 3.2.5-SNAPSHOT../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
index b216b5bc..47747a5d 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4
+ 3.2.5-SNAPSHOT../../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml
index c0cb671d..02a1c416 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4
+ 3.2.5-SNAPSHOT../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml
index 0881e3a1..572a9558 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml
@@ -18,7 +18,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4
+ 3.2.5-SNAPSHOT../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml
index a4d0e9d6..1029a806 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml
@@ -20,7 +20,7 @@
com.wso2.openbanking.accelerator.runtimecom.wso2.openbanking.accelerator
- 3.2.4
+ 3.2.5-SNAPSHOT../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml
index 5fa59b91..f068ecd0 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4
+ 3.2.5-SNAPSHOT../../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml
index 2ed5626e..4ca181b4 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4
+ 3.2.5-SNAPSHOT../../pom.xml
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml
index d5687212..4eab4130 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4
+ 3.2.5-SNAPSHOT../../../pom.xml
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
index ffdc18fa..07ff90c2 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4
+ 3.2.5-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml
index 60533b24..97e21a62 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml
@@ -21,7 +21,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4
+ 3.2.5-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml
index f802b1fd..7dec03bc 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml
@@ -19,7 +19,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4
+ 3.2.5-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml
index 96ee9fa5..0c4e85a9 100644
--- a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml
+++ b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4
+ 3.2.5-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml
index 7ce0d757..9802f8c6 100644
--- a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml
+++ b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4
+ 3.2.5-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml
index cfd9a53a..2e000548 100755
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml
@@ -21,7 +21,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4
+ 3.2.5-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml
index 69e51a6d..d7b0d816 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml
@@ -18,7 +18,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4
+ 3.2.5-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml
index 08166b2d..29de591a 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4
+ 3.2.5-SNAPSHOT../../../pom.xml
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
index 4ca45216..1e89ac64 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4
+ 3.2.5-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml
index 9f2fcfb2..1f0da4cb 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml
@@ -21,7 +21,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4
+ 3.2.5-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml
index e25f9af2..30e47eba 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml
@@ -19,7 +19,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4
+ 3.2.5-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml
index 90f9af39..e9643953 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4
+ 3.2.5-SNAPSHOT../../../pom.xml
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml
index f8fbaa2e..6e90bf75 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml
@@ -21,7 +21,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.4
+ 3.2.5-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/pom.xml b/open-banking-accelerator/pom.xml
index e5b7e563..4b5c1710 100644
--- a/open-banking-accelerator/pom.xml
+++ b/open-banking-accelerator/pom.xml
@@ -23,14 +23,14 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.2.4
+ 3.2.5-SNAPSHOT../pom.xmlWSO2 Open Banking Acceleratoropen-banking-acceleratorpom
- 3.2.4
+ 3.2.5-SNAPSHOTcomponents/com.wso2.openbanking.accelerator.common
diff --git a/pom.xml b/pom.xml
index 26895155..e7ec9cf7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,7 +21,7 @@
com.wso2.openbanking.acceleratoropen-bankingpom
- 3.2.4
+ 3.2.5-SNAPSHOTorg.wso2
@@ -172,7 +172,7 @@
https://github.com/wso2/financial-open-banking.gitscm:git:https://github.com/wso2/financial-open-banking.gitscm:git:https://github.com/wso2/financial-open-banking.git
- v3.2.4
+ HEAD
diff --git a/react-apps/pom.xml b/react-apps/pom.xml
index fb824fe0..2f331317 100644
--- a/react-apps/pom.xml
+++ b/react-apps/pom.xml
@@ -23,7 +23,7 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.2.4
+ 3.2.5-SNAPSHOT../pom.xml
diff --git a/react-apps/self-care-portal/pom.xml b/react-apps/self-care-portal/pom.xml
index 4eb2c523..aba66ad3 100644
--- a/react-apps/self-care-portal/pom.xml
+++ b/react-apps/self-care-portal/pom.xml
@@ -23,7 +23,7 @@
com.wso2.openbanking.acceleratorreact-apps
- 3.2.4
+ 3.2.5-SNAPSHOT../pom.xml
From c3c0e71b54f91f9c0ba0a13d8eaa866b7aadd55c Mon Sep 17 00:00:00 2001
From: ImalshaD
Date: Thu, 9 May 2024 12:31:15 +0530
Subject: [PATCH 142/281] App2App Authenticator structure changed
---
.../accelerator/common/util/JWTUtils.java | 127 +++++++++++-
.../identity/app2app/App2AppAuthUtil.java | 178 ----------------
.../app2app/App2AppAuthenticator.java | 193 ++++--------------
.../App2AppAuthenticatorConstants.java | 20 +-
.../exception/SecretValidationException.java | 4 +-
.../identity/app2app/model/Secret.java | 77 +++++--
.../app2app/utils/App2AppAuthUtils.java | 154 ++++++++++++++
.../app2app/validations/JTIValidator.java | 43 ++++
.../JwtTokenTimelinessValidator.java | 28 +++
.../validations/SignatureValidator.java | 53 ++++-
.../validations/annotations/ValidateJTI.java | 3 +-
.../annotations/ValidateNotValidBefore.java | 24 ---
.../annotations/ValidateSignature.java | 3 +-
...ateExpiry.java => ValidateTimeliness.java} | 8 +-
.../validationgroups/ValidationOrder.java | 7 +
.../app2app/App2AppAuthenticatorTest.java | 14 --
.../MTLSCertificateValidatorTest.java | 2 +-
17 files changed, 515 insertions(+), 423 deletions(-)
delete mode 100644 open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthUtil.java
create mode 100644 open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/utils/App2AppAuthUtils.java
create mode 100644 open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JTIValidator.java
create mode 100644 open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JwtTokenTimelinessValidator.java
delete mode 100644 open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateNotValidBefore.java
rename open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/{ValidateExpiry.java => ValidateTimeliness.java} (65%)
create mode 100644 open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/validationgroups/ValidationOrder.java
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/JWTUtils.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/JWTUtils.java
index 638f56f5..5d741702 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/JWTUtils.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/JWTUtils.java
@@ -20,6 +20,8 @@
import com.nimbusds.jose.JOSEException;
import com.nimbusds.jose.JWSAlgorithm;
import com.nimbusds.jose.JWSObject;
+import com.nimbusds.jose.JWSVerifier;
+import com.nimbusds.jose.crypto.RSASSAVerifier;
import com.nimbusds.jose.jwk.source.RemoteJWKSet;
import com.nimbusds.jose.proc.BadJOSEException;
import com.nimbusds.jose.proc.JWSKeySelector;
@@ -42,7 +44,14 @@
import java.net.MalformedURLException;
import java.net.URL;
+import java.security.KeyFactory;
+import java.security.NoSuchAlgorithmException;
+import java.security.interfaces.RSAPublicKey;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.X509EncodedKeySpec;
import java.text.ParseException;
+import java.util.Base64;
+import java.util.Date;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -128,12 +137,27 @@ public static boolean validateJWTSignature(String jwtString, String jwksUri, Str
return true;
}
- public static SignedJWT getSignedJWT(String jwtString) throws ParseException {
- if (isJWT(jwtString)){
- return SignedJWT.parse(jwtString);
- }else{
- throw new IllegalArgumentException("Provided token identifier is not a parsable JWT.");
- }
+ /**
+ *Validates the signature of a given JWT against a given public key.
+ *
+ * @param signedJWT the signed JWT to be validated
+ * @param publicKey the public key that ois used for validation
+ * @param algorithm the algorithm expected to have signed the jwt
+ * @return true if signature is valid else false
+ * @throws NoSuchAlgorithmException if the given algorithm doesn't exist
+ * @throws InvalidKeySpecException if the provided key is invalid
+ * @throws JOSEException if an error occurs during the signature validation process
+ */
+ public static boolean validateJWTSignature(SignedJWT signedJWT, String publicKey, String algorithm) throws
+ NoSuchAlgorithmException, InvalidKeySpecException, JOSEException {
+
+ byte[] publicKeyData = Base64.getDecoder().decode(publicKey);
+ X509EncodedKeySpec spec = new X509EncodedKeySpec(publicKeyData);
+ KeyFactory kf = KeyFactory.getInstance(algorithm);
+ RSAPublicKey rsapublicKey = (RSAPublicKey) kf.generatePublic(spec);
+ JWSVerifier verifier = new RSASSAVerifier(rsapublicKey);
+ return signedJWT.verify(verifier);
+
}
/**
@@ -142,7 +166,8 @@ public static SignedJWT getSignedJWT(String jwtString) throws ParseException {
* @param jwtString JWT string
*/
public static boolean isJWT(String jwtString) {
- if (jwtString == null){
+
+ if (jwtString == null) {
return false;
}
if (StringUtils.isBlank(jwtString)) {
@@ -152,6 +177,7 @@ public static boolean isJWT(String jwtString) {
return false;
}
try {
+ //Checking whether the jwtString is jwt parsable.
JWTParser.parse(jwtString);
return true;
} catch (ParseException e) {
@@ -160,14 +186,97 @@ public static boolean isJWT(String jwtString) {
}
return false;
}
+
}
- public static JWTClaimsSet getJWTClaimsSet(SignedJWT signedJWT) throws ParseException{
+ /**
+ * Parses the provided JWT string into a SignedJWT object.
+ *
+ * @param jwtString the JWT string to parse
+ * @return the parsed SignedJWT object
+ * @throws IllegalArgumentException if the provided token identifier is not a parsable JWT
+ * Will not throw ParseException as it is already validated by isJWT
+ */
+ public static SignedJWT getSignedJWT(String jwtString) throws ParseException {
+
+ if (isJWT(jwtString)) {
+ return SignedJWT.parse(jwtString);
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("Provided token identifier is not a parsable JWT.");
+ }
+ throw new IllegalArgumentException("Provided token identifier is not a parsable JWT.");
+ }
+
+ }
+
+ /**
+ * Extracts the JWT claims set from the provided SignedJWT object.
+ *
+ * @param signedJWT the signedJWT object from which the claims are extracted
+ * @return extracted jwt claims set in JWTClaimsSet object
+ * @throws ParseException if the signedJWT is corrupted
+ */
+ public static JWTClaimsSet getJWTClaimsSet(SignedJWT signedJWT) throws ParseException {
+
return signedJWT.getJWTClaimsSet();
+
}
- public static T getClaim(JWTClaimsSet jwtClaimsSet ,String claim){
+ /**
+ * Retrieves the value of the specified claim from the provided JWTClaimsSet.
+ *
+ * @param jwtClaimsSet the JWTClaimsSet from which to retrieve the claim value
+ * @param claim the name of the claim to retrieve
+ * @param the type of the claim value
+ * @return the value of the specified claim, or null if the claim is not present
+ */
+ public static T getClaim(JWTClaimsSet jwtClaimsSet , String claim) {
+
Object claimObj = jwtClaimsSet.getClaim(claim);
return (T) claimObj;
+
+ }
+
+ /**
+ * Validates whether a given JWT is not expired.
+ *
+ * @param jwtClaimsSet jwt claims set of the jwt that needs to validated
+ * @return true if the jwt is not expired
+ */
+ public static boolean validateExpiryTime(JWTClaimsSet jwtClaimsSet) {
+
+ Date expirationTime = jwtClaimsSet.getExpirationTime();
+ if (expirationTime != null) {
+ long timeStampSkewMillis = DEFAULT_TIME_SKEW_IN_SECONDS * 1000;
+ long expirationTimeInMillis = expirationTime.getTime();
+ long currentTimeInMillis = System.currentTimeMillis();
+ return (currentTimeInMillis + timeStampSkewMillis) <= expirationTimeInMillis;
+ } else {
+ return false;
+ }
+
+ }
+
+ /**
+ * Validates whether a given JWT is active.
+ *
+ * @param jwtClaimsSet jwt claims set of the jwt that needs to validated
+ * @return true if the jwt is active
+ */
+ public static boolean validateNotValidBefore(JWTClaimsSet jwtClaimsSet) {
+
+ Date notBeforeTime = jwtClaimsSet.getNotBeforeTime();
+ if (notBeforeTime != null) {
+ long timeStampSkewMillis = DEFAULT_TIME_SKEW_IN_SECONDS * 1000;
+ long notBeforeTimeMillis = notBeforeTime.getTime();
+ long currentTimeInMillis = System.currentTimeMillis();
+ return currentTimeInMillis + timeStampSkewMillis >= notBeforeTimeMillis;
+
+ } else {
+ return false;
+ }
+
}
}
+
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthUtil.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthUtil.java
deleted file mode 100644
index 62aa9e93..00000000
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthUtil.java
+++ /dev/null
@@ -1,178 +0,0 @@
-package com.wso2.openbanking.accelerator.identity.app2app;
-
-import com.nimbusds.jose.JOSEException;
-import com.nimbusds.jose.JWSVerifier;
-import com.nimbusds.jose.crypto.RSASSAVerifier;
-import com.nimbusds.jwt.JWTClaimsSet;
-import com.nimbusds.jwt.JWTParser;
-import com.nimbusds.jwt.SignedJWT;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.identity.application.authenticator.push.common.exception.PushAuthTokenValidationException;
-
-import java.security.KeyFactory;
-import java.security.NoSuchAlgorithmException;
-import java.security.interfaces.RSAPublicKey;
-import java.security.spec.InvalidKeySpecException;
-import java.security.spec.X509EncodedKeySpec;
-import java.text.ParseException;
-import java.util.Base64;
-import java.util.Date;
-
-public class App2AppAuthUtil {
-
- private static final String DOT_SEPARATOR = ".";
- private static final long DEFAULT_TIME_SKEW_IN_SECONDS = 300L;
- private static final Log log = LogFactory.getLog(App2AppAuthUtil.class);
-
- /**
- * Validate legitimacy of JWT.
- *
- * @param jwtString JWT string
- */
- public static boolean isJWT(String jwtString) {
- if (jwtString == null){
- return false;
- }
- if (StringUtils.isBlank(jwtString)) {
- return false;
- }
- if (StringUtils.countMatches(jwtString, DOT_SEPARATOR) != 2) {
- return false;
- }
- try {
- JWTParser.parse(jwtString);
- return true;
- } catch (ParseException e) {
- if (log.isDebugEnabled()) {
- log.debug("Provided token identifier is not a parsable JWT.", e);
- }
- return false;
- }
- }
-
- public static SignedJWT getSignedJWT(String jwtString) throws ParseException {
- if (isJWT(jwtString)){
- return SignedJWT.parse(jwtString);
- }else{
- throw new IllegalArgumentException("Required parameter jwtString is invalid");
- }
- }
-
- public static JWTClaimsSet getJWTClaimsSet(String jwtString) throws ParseException{
- return getJWTClaimsSet(getSignedJWT(jwtString));
- }
-
- public static JWTClaimsSet getJWTClaimsSet(SignedJWT signedJWT) throws ParseException{
- return signedJWT.getJWTClaimsSet();
- }
-
- public static T getClaim(String jwtString, String claim) throws ParseException{
- return getClaim(getJWTClaimsSet(jwtString),claim);
- }
-
- public static T getClaim(JWTClaimsSet jwtClaimsSet ,String claim){
- Object claimObj = jwtClaimsSet.getClaim(claim);
- return (T) claimObj;
- }
-
- public static T getClaim(SignedJWT signedJWT ,String claim) throws ParseException {
- return getClaim(getJWTClaimsSet(signedJWT),claim);
- }
-
- public static boolean validateJWT(SignedJWT signedJWT, String publicKey, String algorithm)
- throws PushAuthTokenValidationException{
- try {
- if (!validateSignature(signedJWT,publicKey,algorithm)){
- return false;
- }
- if (!validateExpiryTime(signedJWT)){
- return false;
- }
- if (!validateNotValidBefore(signedJWT)){
- return false;
- }
- return true;
- } catch (NoSuchAlgorithmException e) {
- throw new PushAuthTokenValidationException("Error occurred while validating JWT. No such algorithm "
- +algorithm,e);
- } catch (InvalidKeySpecException e) {
- throw new PushAuthTokenValidationException("Error occurred while validating JWT. Invalid Key Space",e);
- } catch (JOSEException e) {
- throw new PushAuthTokenValidationException("Error occurred while verifying JWT.",e);
- } catch (ParseException e) {
- throw new PushAuthTokenValidationException("Error occurred while parsing JWT.",e);
- }
- }
-
- public static boolean validateJWT(String jwtString,String publicKey, String algorithm) throws PushAuthTokenValidationException {
- SignedJWT signedJWT = null;
- try {
- signedJWT = getSignedJWT(jwtString);
- } catch (ParseException e) {
- throw new PushAuthTokenValidationException("Error occurred while parsing JWT.",e);
- }
- return validateJWT(signedJWT, publicKey, algorithm);
- }
-
- public static boolean validateSignature(SignedJWT signedJWT, String publicKey, String algorithm) throws
- NoSuchAlgorithmException, InvalidKeySpecException, JOSEException {
- byte[] publicKeyData = Base64.getDecoder().decode(publicKey);
- X509EncodedKeySpec spec = new X509EncodedKeySpec(publicKeyData);
- KeyFactory kf = KeyFactory.getInstance(algorithm);
- RSAPublicKey rsapublicKey = (RSAPublicKey) kf.generatePublic(spec);
- JWSVerifier verifier = new RSASSAVerifier(rsapublicKey);
- return signedJWT.verify(verifier);
- }
-
- public static boolean validateSignature(String jwtString, String publicKey, String algorithm) throws
- NoSuchAlgorithmException, InvalidKeySpecException, JOSEException, ParseException {
- SignedJWT signedJWT = getSignedJWT(jwtString);
- return validateSignature(signedJWT,publicKey,algorithm);
- }
-
- public static boolean validateExpiryTime(JWTClaimsSet jwtClaimsSet){
- Date expirationTime = jwtClaimsSet.getExpirationTime();
- if (expirationTime != null) {
- long timeStampSkewMillis = DEFAULT_TIME_SKEW_IN_SECONDS * 1000;
- long expirationTimeInMillis = expirationTime.getTime();
- long currentTimeInMillis = System.currentTimeMillis();
- return (currentTimeInMillis + timeStampSkewMillis) <= expirationTimeInMillis;
- }else{
- return false;
- }
- }
- public static boolean validateExpiryTime(SignedJWT signedJWT) throws ParseException {
- JWTClaimsSet jwtClaimsSet = getJWTClaimsSet(signedJWT);
- return validateExpiryTime(jwtClaimsSet);
- }
-
- public static boolean validateExpiryTime(String jwtString) throws ParseException {
- SignedJWT signedJWT = getSignedJWT(jwtString);
- return validateExpiryTime(signedJWT);
- }
-
- public static boolean validateNotValidBefore(JWTClaimsSet jwtClaimsSet){
- Date notBeforeTime = jwtClaimsSet.getNotBeforeTime();
- if (notBeforeTime != null) {
- long timeStampSkewMillis = DEFAULT_TIME_SKEW_IN_SECONDS * 1000;
- long notBeforeTimeMillis = notBeforeTime.getTime();
- long currentTimeInMillis = System.currentTimeMillis();
- return currentTimeInMillis + timeStampSkewMillis >= notBeforeTimeMillis;
-
- } else {
- return false;
- }
- }
- public static boolean validateNotValidBefore(SignedJWT signedJWT) throws ParseException {
- JWTClaimsSet jwtClaimsSet = getJWTClaimsSet(signedJWT);
- return validateNotValidBefore(jwtClaimsSet);
- }
-
- public static boolean validateNotValidBefore(String jwtString) throws ParseException {
- SignedJWT signedJWT = getSignedJWT(jwtString);
- return validateNotValidBefore(signedJWT);
- }
-
-}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticator.java
index ea1f3132..12a7d90b 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticator.java
@@ -1,10 +1,10 @@
package com.wso2.openbanking.accelerator.identity.app2app;
-import com.nimbusds.jwt.JWTClaimsSet;
-import com.nimbusds.jwt.SignedJWT;
+
+import com.wso2.openbanking.accelerator.identity.app2app.exception.SecretValidationException;
+import com.wso2.openbanking.accelerator.identity.app2app.model.Secret;
+import com.wso2.openbanking.accelerator.identity.app2app.utils.App2AppAuthUtils;
import com.wso2.openbanking.accelerator.identity.cache.IdentityCache;
-import com.wso2.openbanking.accelerator.identity.cache.IdentityCacheKey;
-import com.wso2.openbanking.accelerator.identity.internal.IdentityExtensionsDataHolder;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -12,26 +12,18 @@
import org.wso2.carbon.identity.application.authentication.framework.exception.AuthenticationFailedException;
import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser;
import org.wso2.carbon.identity.application.authenticator.push.PushAuthenticator;
-import org.wso2.carbon.identity.application.authenticator.push.common.exception.PushAuthTokenValidationException;
-import org.wso2.carbon.identity.application.authenticator.push.device.handler.exception.PushDeviceHandlerClientException;
-import org.wso2.carbon.identity.application.authenticator.push.device.handler.exception.PushDeviceHandlerServerException;
-import org.wso2.carbon.identity.application.authenticator.push.device.handler.impl.DeviceHandlerImpl;
-import org.wso2.carbon.identity.application.authenticator.push.device.handler.model.Device;
import org.wso2.carbon.identity.application.common.model.Property;
-import org.wso2.carbon.identity.core.util.IdentityTenantUtil;
-import org.wso2.carbon.user.api.UserRealm;
-import org.wso2.carbon.user.api.UserStoreException;
-import org.wso2.carbon.user.core.common.AbstractUserStoreManager;
-import org.wso2.carbon.user.core.service.RealmService;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Optional;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * App2App authenticator for authenticating users from native auth attempt.
+ */
public class App2AppAuthenticator extends PushAuthenticator {
private static IdentityCache identityCache;
@@ -40,161 +32,65 @@ public class App2AppAuthenticator extends PushAuthenticator {
@Override
public String getName() {
+
return App2AppAuthenticatorConstants.AUTHENTICATOR_NAME;
+
}
@Override
public String getFriendlyName() {
+
return App2AppAuthenticatorConstants.AUTHENTICATOR_FRIENDLY_NAME;
+
}
@Override
protected void processAuthenticationResponse(HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse,
AuthenticationContext authenticationContext)
throws AuthenticationFailedException {
- AuthenticatedUser user = this.getAuthenticatedUser(httpServletRequest);
- authenticationContext.setSubject(user);
+
String jwtString = httpServletRequest.getParameter(App2AppAuthenticatorConstants.SECRET);
try {
- SignedJWT signedJWT = App2AppAuthUtil.getSignedJWT(jwtString);
- JWTClaimsSet jwtClaimsSet = App2AppAuthUtil.getJWTClaimsSet(signedJWT);
- String jti = App2AppAuthUtil.getClaim(jwtClaimsSet,App2AppAuthenticatorConstants.JTI);
- if (!validateJTI(jti)){
- throw new AuthenticationFailedException("JTI value "+jti+" has been replayed.");
- };
- if (!validateAppAuthAttempt(user,signedJWT,jwtClaimsSet)){
- throw new AuthenticationFailedException("JWT validation failed.");
- };
- } catch (PushDeviceHandlerServerException e) {
- throw new AuthenticationFailedException("Error occurred when trying to redirect to the registered devices"
- + " page. Devices were not found for user: " + user.toFullQualifiedUsername() + ".", e);
- } catch (PushAuthTokenValidationException e) {
- throw new AuthenticationFailedException("JWT Token validation Failed",e);
- } catch (UserStoreException e) {
- throw new AuthenticationFailedException("Error occurred when trying to get the user ID for user: "
- + user.toFullQualifiedUsername() + ".", e);
- } catch (PushDeviceHandlerClientException e) {
- throw new AuthenticationFailedException("Error occurred when trying to get user claims for user: "
- + user.toFullQualifiedUsername() + ".", e);
- } catch (ParseException e) {
- throw new AuthenticationFailedException("Error while parsing JWT.",e);
- } catch (IllegalArgumentException e){
- throw new AuthenticationFailedException(e.getMessage(),e);
- }
-
- }
-
- private boolean validateAppAuthAttempt(AuthenticatedUser user, SignedJWT signedJWT,
- JWTClaimsSet jwtClaimsSet)
- throws AuthenticationFailedException, UserStoreException,
- PushDeviceHandlerServerException, PushDeviceHandlerClientException,
- PushAuthTokenValidationException {
- String userID = getUserIdFromUsername(user.getUserName(), getUserRealm(user));
- String deviceID = App2AppAuthUtil.getClaim(jwtClaimsSet,App2AppAuthenticatorConstants.DEVICE_IDENTIFIER);
- String publicKey;
- if (!StringUtils.isBlank(deviceID)) {
- publicKey = getPublicKey(deviceID, userID);
- }else{
- throw new IllegalArgumentException("Required Parameter deviceId is null or empty.");
- }
- return App2AppAuthUtil.validateJWT(signedJWT,publicKey,
- App2AppAuthenticatorConstants.SIGNING_ALGORITHM);
- }
-
- private Device getRegisteredDevice(String deviceId, String userID)
- throws PushDeviceHandlerServerException, IllegalArgumentException, PushDeviceHandlerClientException {
- DeviceHandlerImpl deviceHandler = new DeviceHandlerImpl();
- List deviceList = deviceHandler.listDevices(userID);
- for (Device device : deviceList) {
- if (StringUtils.equals(device.getDeviceId(),deviceId)){
- String publicKey = deviceHandler.getPublicKey(deviceId);
- device.setPublicKey(publicKey);
- return device;
- }
- }
- throw new IllegalArgumentException("Provided device Identifier does not exist.");
- }
-
- private boolean validateJTI(String jti) throws IllegalArgumentException {
- if (!StringUtils.isBlank(jti)){
- IdentityCacheKey jtiCacheKey = new IdentityCacheKey(jti);
- if (getFromCache(jtiCacheKey) != null){
- return false;
- }
- addToCache(jtiCacheKey,jti);
- return true;
- }else{
- throw new IllegalArgumentException("Required parameter jti null or empty in JWT.");
- }
- }
-
- private Object getFromCache(IdentityCacheKey identityCacheKey){
- if (identityCache == null){
- identityCache = new IdentityCache();
- }
- return identityCache.getFromCache(identityCacheKey);
- }
-
- private void addToCache(IdentityCacheKey identityCacheKey, Object value){
- if (identityCache == null){
- identityCache = new IdentityCache();
+ Secret secret = new Secret(jwtString);
+ App2AppAuthUtils.getValidationViolations(secret);
+ AuthenticatedUser user = secret.getAuthenticatedUser();
+ authenticationContext.setSubject(user);
+ } catch (SecretValidationException e) {
+ throw new AuthenticationFailedException(e.getMessage());
+ } catch (IllegalArgumentException e) {
+ throw new AuthenticationFailedException("Illegal Argument exception: " + e.getMessage(), e);
+ } catch (RuntimeException e) {
+ throw new AuthenticationFailedException("Run Time exception: " + e.getMessage(), e);
}
- identityCache.addToCache(identityCacheKey,value);
- }
-
- private String getPublicKeyFromDevice(Device device){
- return device.getPublicKey();
- }
-
- private String getPublicKey(String deviceID, String userID)
- throws PushDeviceHandlerServerException,
- IllegalArgumentException, PushDeviceHandlerClientException {
- return getPublicKeyFromDevice(getRegisteredDevice(deviceID,userID));
- }
-
- private String getUserIdFromUsername(String username, UserRealm realm) throws UserStoreException {
-
- AbstractUserStoreManager userStoreManager = (AbstractUserStoreManager) realm.getUserStoreManager();
- return userStoreManager.getUserIDFromUserName(username);
- }
-
- private UserRealm getUserRealm(AuthenticatedUser authenticatedUser) throws AuthenticationFailedException {
-
- UserRealm userRealm = null;
- try {
- if (authenticatedUser != null) {
- String tenantDomain = authenticatedUser.getTenantDomain();
- int tenantId = IdentityTenantUtil.getTenantId(tenantDomain);
- RealmService realmService = IdentityExtensionsDataHolder.getInstance().getRealmService();
- userRealm = realmService.getTenantUserRealm(tenantId);
- }
- } catch (UserStoreException e) {
- throw new AuthenticationFailedException("Error occurred when trying to get the user realm for user: "
- + authenticatedUser.toFullQualifiedUsername() + ".", e);
- }
- return userRealm;
}
@Override
public boolean canHandle(HttpServletRequest httpServletRequest) {
+
return !StringUtils.isBlank(httpServletRequest.getParameter(App2AppAuthenticatorConstants.SECRET));
+
}
@Override
public String getContextIdentifier(HttpServletRequest request) {
+
return request.getParameter(App2AppAuthenticatorConstants.SESSION_DATA_KEY);
+
}
@Override
- protected void initiateAuthenticationRequest(HttpServletRequest request, HttpServletResponse response, AuthenticationContext context)
- throws AuthenticationFailedException {
+ protected void initiateAuthenticationRequest(HttpServletRequest request, HttpServletResponse response,
+ AuthenticationContext context) throws AuthenticationFailedException {
+
throw new AuthenticationFailedException("Mandatory parameter secret null or empty in request.");
}
+ //TODO : remove this configuration properties.
@Override
public List getConfigurationProperties() {
+
List configProperties = new ArrayList<>();
String firebaseServerKey = "Firebase Server Key";
Property serverKeyProperty = new Property();
@@ -205,26 +101,7 @@ public List getConfigurationProperties() {
serverKeyProperty.setRequired(true);
configProperties.add(serverKeyProperty);
return configProperties;
- }
- protected AuthenticatedUser getAuthenticatedUser(HttpServletRequest request) {
- String secretJWT = request.getParameter(App2AppAuthenticatorConstants.SECRET);
- String loginHint;
- try {
- loginHint = App2AppAuthUtil.getClaim(secretJWT,App2AppAuthenticatorConstants.LOGIN_HINT);
- } catch (ParseException e) {
- throw new RuntimeException(e);
- }
- if (!StringUtils.isBlank(loginHint)){
- return AuthenticatedUser.createLocalAuthenticatedUserFromSubjectIdentifier(loginHint);
- }else{
- throw new IllegalArgumentException("Required Parameter Login Hint is null or empty");
- }
}
- protected Optional getAdditionalInfo(HttpServletRequest request, HttpServletResponse response,
- java.lang.String sessionDataKey) throws AuthenticationFailedException {
- return Optional.empty();
- }
-
-
}
+
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorConstants.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorConstants.java
index 5106443a..aa7a2a04 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorConstants.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorConstants.java
@@ -1,33 +1,25 @@
package com.wso2.openbanking.accelerator.identity.app2app;
+/**
+ * Constants related with App2App Authenticator process.
+ */
public class App2AppAuthenticatorConstants {
public static final String AUTHENTICATOR_NAME = "app2app";
public static final String AUTHENTICATOR_FRIENDLY_NAME = "App2App Authenticator";
+
public static final String REQUEST = "request";
- public static final String REQUEST_OBJECT = "request_object";
- public static final String BINDING_MESSAGE = "binding_message";
- //Consent Related constants
- public static final String LOGGED_IN_USER = "loggedInUser";
- public static final String USER_TENANT_DOMAIN = "userTenantDomain";
public static final String SCOPE = "scope";
+
public static final String APPLICATION = "application";
- public static final String CONSENT_PROMPTED = "consentPrompted";
- public static final String AUTH_REQ_ID = "auth_req_id";
- public static final String NONCE = "nonce";
public static final String LOGIN_HINT = "loginHint";
public static final String DEVICE_IDENTIFIER = "did";
public static final String SIGNING_ALGORITHM = "RSA";
public static final String SECRET = "secret";
- public static final String SP_QUERY_PARAMS = "spQueryParams";
- // error constants
public static final String IS_ERROR = "isError";
- public static final String ERROR_SERVER_ERROR = "Internal server error";
- public static final String ERROR_NO_TYPE_AND_APP_DATA = "Type and application data is unavailable";
- public static final String ERROR_DESCRIPTION = "error_description";
+
public static final String ERROR = "error";
- public static final String JTI = "jti";
public static final String SESSION_DATA_KEY = "sessionDataKey";
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/exception/SecretValidationException.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/exception/SecretValidationException.java
index 5c2c1242..c102dc7a 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/exception/SecretValidationException.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/exception/SecretValidationException.java
@@ -3,7 +3,7 @@
import com.wso2.openbanking.accelerator.common.exception.OpenBankingException;
/**
- * Secret Object Validation Exception
+ * Secret Object Validation Exception.
*/
public class SecretValidationException extends OpenBankingException {
@@ -17,4 +17,4 @@ public SecretValidationException(String message) {
public SecretValidationException(String message, Throwable e) {
super(message, e);
}
-}
\ No newline at end of file
+}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/Secret.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/Secret.java
index 4e34abb8..7d068ee7 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/Secret.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/Secret.java
@@ -6,14 +6,25 @@
import com.wso2.openbanking.accelerator.common.util.JWTUtils;
import com.wso2.openbanking.accelerator.identity.app2app.App2AppAuthenticatorConstants;
import com.wso2.openbanking.accelerator.identity.app2app.exception.SecretValidationException;
+import com.wso2.openbanking.accelerator.identity.app2app.validations.annotations.ValidateJTI;
+import com.wso2.openbanking.accelerator.identity.app2app.validations.annotations.ValidateSignature;
+import com.wso2.openbanking.accelerator.identity.app2app.validations.annotations.ValidateTimeliness;
+import com.wso2.openbanking.accelerator.identity.app2app.validations.validationgroups.RequiredParamChecks;
+import com.wso2.openbanking.accelerator.identity.app2app.validations.validationgroups.ValidityChecks;
+import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser;
-import javax.validation.constraints.NotBlank;
import java.text.ParseException;
import java.util.Date;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
/**
- * Model class for App2App Auth Secret
+ * Model class for App2App Auth Secret.
*/
+@ValidateJTI(groups = ValidityChecks.class)
+@ValidateSignature(algorithm = App2AppAuthenticatorConstants.SIGNING_ALGORITHM, groups = ValidityChecks.class)
+@ValidateTimeliness(groups = ValidityChecks.class)
public class Secret {
@SerializedName("did")
private String deviceId;
@@ -29,25 +40,29 @@ public class Secret {
private Date issuedTime;
private SignedJWT signedJWT;
private JWTClaimsSet jwtClaimsSet;
+ private String publicKey;
+ private AuthenticatedUser authenticatedUser;
public Secret(String jwtString) throws SecretValidationException {
+
try {
this.signedJWT = JWTUtils.getSignedJWT(jwtString);
this.jwtClaimsSet = JWTUtils.getJWTClaimsSet(this.signedJWT);
this.expirationTime = jwtClaimsSet.getExpirationTime();
this.notValidBefore = jwtClaimsSet.getNotBeforeTime();
this.issuedTime = jwtClaimsSet.getIssueTime();
- this.jti = JWTUtils.getClaim(jwtClaimsSet, App2AppAuthenticatorConstants.JTI);
- this.deviceId = JWTUtils.getClaim(jwtClaimsSet,App2AppAuthenticatorConstants.DEVICE_IDENTIFIER);
- this.loginHint = JWTUtils.getClaim(jwtClaimsSet,App2AppAuthenticatorConstants.LOGIN_HINT);
+ this.jti = jwtClaimsSet.getJWTID();
+ this.deviceId = JWTUtils.getClaim(jwtClaimsSet, App2AppAuthenticatorConstants.DEVICE_IDENTIFIER);
+ this.loginHint = JWTUtils.getClaim(jwtClaimsSet, App2AppAuthenticatorConstants.LOGIN_HINT);
} catch (ParseException e) {
- throw new SecretValidationException("Error while parsing JWT.",e);
- } catch (IllegalArgumentException e){
+ throw new SecretValidationException("Error while parsing JWT.", e);
+ } catch (IllegalArgumentException e) {
throw new SecretValidationException(e.getMessage());
}
+
}
- @NotBlank(message = "Required Parameter did cannot be null or empty.")
+ @NotBlank(message = "Required Parameter did cannot be null or empty.", groups = RequiredParamChecks.class)
public String getDeviceId() {
return deviceId;
}
@@ -55,14 +70,14 @@ public String getDeviceId() {
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
- @NotBlank(message = "Required Parameter loginHint cannot be null or empty.")
+ @NotBlank(message = "Required Parameter loginHint cannot be null or empty.", groups = RequiredParamChecks.class)
public String getLoginHint() {
return loginHint;
}
public void setLoginHint(String loginHint) {
this.loginHint = loginHint;
}
- @NotBlank(message = "Required Parameter exp cannot be null or empty.")
+ @NotNull(message = "Required Parameter exp cannot be null or empty.", groups = RequiredParamChecks.class)
public Date getExpirationTime() {
return expirationTime;
}
@@ -70,7 +85,7 @@ public Date getExpirationTime() {
public void setExpirationTime(Date expirationTime) {
this.expirationTime = expirationTime;
}
- @NotBlank(message = "Required Parameter nbf cannot be null or empty.")
+ @NotNull(message = "Required Parameter nbf cannot be null or empty.", groups = RequiredParamChecks.class)
public Date getNotValidBefore() {
return notValidBefore;
}
@@ -78,7 +93,7 @@ public Date getNotValidBefore() {
public void setNotValidBefore(Date notValidBefore) {
this.notValidBefore = notValidBefore;
}
- @NotBlank(message = "Required Parameter jti cannot be null or empty.")
+ @NotBlank(message = "Required Parameter jti cannot be null or empty.", groups = RequiredParamChecks.class)
public String getJti() {
return jti;
}
@@ -86,12 +101,44 @@ public String getJti() {
public void setJti(String jti) {
this.jti = jti;
}
- @NotBlank(message = "Required Parameter iat cannot be null or empty.")
- public Date getIssuedAt() {
+ @NotNull(message = "Required Parameter iat cannot be null or empty.", groups = RequiredParamChecks.class)
+ public Date getIssuedTime() {
return issuedTime;
}
- public void setIssuedAt(Date issuedAt) {
+ public void setIssuedTime(Date issuedAt) {
this.issuedTime = issuedAt;
}
+
+ public String getPublicKey() {
+ return publicKey;
+ }
+
+ public void setPublicKey(String publicKey) {
+ this.publicKey = publicKey;
+ }
+ public SignedJWT getSignedJWT() {
+ return signedJWT;
+ }
+
+ public void setSignedJWT(SignedJWT signedJWT) {
+ this.signedJWT = signedJWT;
+ }
+
+ public AuthenticatedUser getAuthenticatedUser() {
+ return authenticatedUser;
+ }
+
+ public void setAuthenticatedUser(AuthenticatedUser authenticatedUser) {
+ this.authenticatedUser = authenticatedUser;
+ }
+
+ public JWTClaimsSet getJwtClaimsSet() {
+ return jwtClaimsSet;
+ }
+
+ public void setJwtClaimsSet(JWTClaimsSet jwtClaimsSet) {
+ this.jwtClaimsSet = jwtClaimsSet;
+ }
}
+
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/utils/App2AppAuthUtils.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/utils/App2AppAuthUtils.java
new file mode 100644
index 00000000..99889b01
--- /dev/null
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/utils/App2AppAuthUtils.java
@@ -0,0 +1,154 @@
+package com.wso2.openbanking.accelerator.identity.app2app.utils;
+
+import com.wso2.openbanking.accelerator.common.validator.OpenBankingValidator;
+import com.wso2.openbanking.accelerator.identity.app2app.exception.SecretValidationException;
+import com.wso2.openbanking.accelerator.identity.app2app.model.Secret;
+import com.wso2.openbanking.accelerator.identity.app2app.validations.validationgroups.ValidationOrder;
+import com.wso2.openbanking.accelerator.identity.internal.IdentityExtensionsDataHolder;
+import org.apache.commons.lang.StringUtils;
+import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser;
+import org.wso2.carbon.identity.application.authenticator.push.device.handler.exception.PushDeviceHandlerClientException;
+import org.wso2.carbon.identity.application.authenticator.push.device.handler.exception.PushDeviceHandlerServerException;
+import org.wso2.carbon.identity.application.authenticator.push.device.handler.impl.DeviceHandlerImpl;
+import org.wso2.carbon.identity.application.authenticator.push.device.handler.model.Device;
+import org.wso2.carbon.identity.core.util.IdentityTenantUtil;
+import org.wso2.carbon.user.api.UserRealm;
+import org.wso2.carbon.user.api.UserStoreException;
+import org.wso2.carbon.user.core.common.AbstractUserStoreManager;
+import org.wso2.carbon.user.core.service.RealmService;
+
+import java.util.List;
+
+/**
+ * Utils class for Authentication related logic implementations.
+ */
+public class App2AppAuthUtils {
+
+ /**
+ * Retrieves an authenticated user object based on the provided subject identifier.
+ *
+ * @param subjectIdentifier the subject identifier used to retrieve the authenticated user
+ * @return an AuthenticatedUser object representing the authenticated user
+ */
+ public static AuthenticatedUser getAuthenticatedUserFromSubjectIdentifier(String subjectIdentifier) {
+
+ return AuthenticatedUser.createLocalAuthenticatedUserFromSubjectIdentifier(subjectIdentifier);
+
+ }
+
+ /**
+ * Retrieves the user realm associated with the provided authenticated user.
+ *
+ * @param authenticatedUser the authenticated user for whom to retrieve the user realm
+ * @return the user realm associated with the authenticated user, or null if the user is not authenticated
+ * @throws UserStoreException if an error occurs while retrieving the user realm
+ */
+ public static UserRealm getUserRealm(AuthenticatedUser authenticatedUser) throws UserStoreException {
+
+ UserRealm userRealm = null;
+
+ if (authenticatedUser != null) {
+ String tenantDomain = authenticatedUser.getTenantDomain();
+ int tenantId = IdentityTenantUtil.getTenantId(tenantDomain);
+ RealmService realmService = IdentityExtensionsDataHolder.getInstance().getRealmService();
+ userRealm = realmService.getTenantUserRealm(tenantId);
+ }
+
+ return userRealm;
+
+ }
+
+ /**
+ * Retrieves the user ID associated with the provided username from the specified user realm.
+ *
+ * @param username the username for which to retrieve the user ID
+ * @param realm the user realm from which to retrieve the user ID
+ * @return the user ID associated with the username
+ * @throws UserStoreException if an error occurs while retrieving the user ID
+ */
+ public static String getUserIdFromUsername(String username, UserRealm realm) throws UserStoreException {
+
+ AbstractUserStoreManager userStoreManager = (AbstractUserStoreManager) realm.getUserStoreManager();
+ return userStoreManager.getUserIDFromUserName(username);
+
+ }
+
+ /**
+ * Retrieves the registered device associated with the specified device ID and user ID.
+ *
+ * @param deviceID the ID of the device to retrieve
+ * @param userID the ID of the user who owns the device
+ * @return the registered device associated with the specified IDs
+ * @throws PushDeviceHandlerServerException if an error occurs on the server side while handling the device
+ * @throws IllegalArgumentException if the provided device identifier does not exist
+ * @throws PushDeviceHandlerClientException if an error occurs on the client side while handling the device
+ */
+ public static Device getRegisteredDevice(String deviceID, String userID) throws PushDeviceHandlerServerException,
+ IllegalArgumentException, PushDeviceHandlerClientException {
+
+ DeviceHandlerImpl deviceHandler = new DeviceHandlerImpl();
+ //Retrieving all the devices registered under userID
+ List deviceList = deviceHandler.listDevices(userID);
+
+ //Iterating and matching the deviceID with specified deviceID
+ for (Device device : deviceList) {
+ //If matches return the device
+ if (StringUtils.equals(device.getDeviceId(), deviceID)) {
+ String publicKey = deviceHandler.getPublicKey(deviceID);
+ device.setPublicKey(publicKey);
+ return device;
+ }
+ }
+
+ //If no device registered for user matches specified deviceID throw exception
+ throw new IllegalArgumentException("Provided device Identifier does not exist.");
+
+ }
+
+ /**
+ * Retrieves the public key associated with the specified device.
+ *
+ * @param device the device from which to retrieve the public key
+ * @return the public key associated with the device
+ */
+ public static String getPublicKeyFromDevice(Device device) {
+
+ return device.getPublicKey();
+
+ }
+
+ /**
+ * Retrieve Public key of the device specified if it is registered under specified user.
+ *
+ * @param deviceID deviceID of the device where the public key is required
+ * @param userID userID of the user
+ * @return the public key
+ * @throws PushDeviceHandlerServerException if an error occurs on the server side while handling the device
+ * @throws IllegalArgumentException if the provided device identifier does not exist
+ * @throws PushDeviceHandlerClientException if an error occurs on the client side while handling the device
+ */
+ public static String getPublicKey(String deviceID, String userID) throws PushDeviceHandlerServerException,
+ IllegalArgumentException, PushDeviceHandlerClientException {
+
+ return getPublicKeyFromDevice(getRegisteredDevice(deviceID, userID));
+
+ }
+
+ /**
+ * Validator util to validate Secret model for given validationOrder.
+ *
+ * @param secret Secret object that needs to be validated
+ * @throws SecretValidationException if validation f
+ */
+ public static void getValidationViolations(Secret secret) throws SecretValidationException {
+
+ String error = OpenBankingValidator.getInstance().getFirstViolation(secret, ValidationOrder.class);
+
+ //if there is a validation violation convert it to secretValidationException
+ if (error != null) {
+ throw new SecretValidationException(error);
+ }
+
+ }
+}
+
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JTIValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JTIValidator.java
new file mode 100644
index 00000000..0e8d29fd
--- /dev/null
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JTIValidator.java
@@ -0,0 +1,43 @@
+package com.wso2.openbanking.accelerator.identity.app2app.validations;
+
+import com.wso2.openbanking.accelerator.identity.app2app.model.Secret;
+import com.wso2.openbanking.accelerator.identity.app2app.validations.annotations.ValidateJTI;
+import com.wso2.openbanking.accelerator.identity.cache.IdentityCache;
+import com.wso2.openbanking.accelerator.identity.cache.IdentityCacheKey;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+public class JTIValidator implements ConstraintValidator {
+ private static IdentityCache identityCache;
+ @Override
+ public boolean isValid(Secret secret, ConstraintValidatorContext constraintValidatorContext) {
+ String jti = secret.getJti();
+ return validateJTI(jti);
+
+ }
+
+ private boolean validateJTI(String jti){
+ IdentityCacheKey jtiCacheKey = new IdentityCacheKey(jti);
+ if (getFromCache(jtiCacheKey) != null){
+ return false;
+ }
+ addToCache(jtiCacheKey,jti);
+ return true;
+
+ }
+
+ private Object getFromCache(IdentityCacheKey identityCacheKey){
+ if (identityCache == null){
+ identityCache = new IdentityCache();
+ }
+ return identityCache.getFromCache(identityCacheKey);
+ }
+
+ private void addToCache(IdentityCacheKey identityCacheKey, Object value){
+ if (identityCache == null){
+ identityCache = new IdentityCache();
+ }
+ identityCache.addToCache(identityCacheKey,value);
+ }
+}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JwtTokenTimelinessValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JwtTokenTimelinessValidator.java
new file mode 100644
index 00000000..5fee61da
--- /dev/null
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JwtTokenTimelinessValidator.java
@@ -0,0 +1,28 @@
+package com.wso2.openbanking.accelerator.identity.app2app.validations;
+
+import com.nimbusds.jwt.JWTClaimsSet;
+import com.wso2.openbanking.accelerator.common.util.JWTUtils;
+import com.wso2.openbanking.accelerator.identity.app2app.model.Secret;
+import com.wso2.openbanking.accelerator.identity.app2app.validations.annotations.ValidateTimeliness;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+public class JwtTokenTimelinessValidator implements ConstraintValidator {
+ private static final Log log = LogFactory.getLog(JwtTokenTimelinessValidator.class);
+ @Override
+ public boolean isValid(Secret secret, ConstraintValidatorContext constraintValidatorContext) {
+ JWTClaimsSet jwtClaimsSet = secret.getJwtClaimsSet();
+ if (!JWTUtils.validateExpiryTime(jwtClaimsSet)){
+ log.error("JWT Expired.");
+ return false;
+ }
+ if (!JWTUtils.validateNotValidBefore(jwtClaimsSet)){
+ log.error("JWT is not active.");
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/SignatureValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/SignatureValidator.java
index 28e9aa9b..49dc848b 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/SignatureValidator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/SignatureValidator.java
@@ -1,20 +1,69 @@
package com.wso2.openbanking.accelerator.identity.app2app.validations;
+import com.nimbusds.jose.JOSEException;
+import com.nimbusds.jwt.SignedJWT;
+import com.wso2.openbanking.accelerator.common.util.JWTUtils;
import com.wso2.openbanking.accelerator.identity.app2app.model.Secret;
+import com.wso2.openbanking.accelerator.identity.app2app.utils.App2AppAuthUtils;
import com.wso2.openbanking.accelerator.identity.app2app.validations.annotations.ValidateSignature;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser;
+import org.wso2.carbon.identity.application.authenticator.push.device.handler.exception.PushDeviceHandlerClientException;
+import org.wso2.carbon.identity.application.authenticator.push.device.handler.exception.PushDeviceHandlerServerException;
+import org.wso2.carbon.user.api.UserRealm;
+import org.wso2.carbon.user.api.UserStoreException;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
-
+import java.security.NoSuchAlgorithmException;
+import java.security.spec.InvalidKeySpecException;
+// TODO: change the name of this implementation
public class SignatureValidator implements ConstraintValidator {
+ private static final Log log = LogFactory.getLog(SignatureValidator.class);
private String algorithm;
@Override
public void initialize(ValidateSignature validateSignature) {
this.algorithm = validateSignature.algorithm();
+
}
@Override
public boolean isValid(Secret secret, ConstraintValidatorContext constraintValidatorContext) {
- return false;
+ try {
+ SignedJWT signedJWT = secret.getSignedJWT();
+ String loginHint = secret.getLoginHint();
+ String deviceID = secret.getDeviceId();
+ AuthenticatedUser authenticatedUser =
+ App2AppAuthUtils.getAuthenticatedUserFromSubjectIdentifier(loginHint);
+ secret.setAuthenticatedUser(authenticatedUser);
+ UserRealm userRealm = App2AppAuthUtils.getUserRealm(authenticatedUser);
+ String userID = App2AppAuthUtils.getUserIdFromUsername(authenticatedUser.getUserName(),userRealm);
+ String publicKey = App2AppAuthUtils.getPublicKey(deviceID,userID);
+ boolean isSignatureValid = JWTUtils.validateJWTSignature(signedJWT,publicKey,algorithm);
+ if (!isSignatureValid){
+ log.error("Signature can't be verified with registered public key.");
+ return false;
+ }
+ } catch (UserStoreException e) {
+ log.error("Error while creating authenticated user.",e);
+ return false;
+ } catch (PushDeviceHandlerServerException e) {
+ log.error("Error occurred push device handler service.",e);
+ return false;
+ } catch (PushDeviceHandlerClientException e) {
+ log.error("Push Device handler client.",e);
+ return false;
+ } catch (NoSuchAlgorithmException e) {
+ log.error("No such algorithm found -"+algorithm+".",e);
+ return false;
+ } catch (InvalidKeySpecException e) {
+ log.error("Invalid key spec.",e);
+ return false;
+ } catch (JOSEException e) {
+ log.error("JOSE exception",e);
+ return false;
+ }
+ return true;
}
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateJTI.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateJTI.java
index f765f407..b0bd7562 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateJTI.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateJTI.java
@@ -1,5 +1,6 @@
package com.wso2.openbanking.accelerator.identity.app2app.validations.annotations;
+import com.wso2.openbanking.accelerator.identity.app2app.validations.JTIValidator;
import com.wso2.openbanking.accelerator.identity.dcr.validation.AlgorithmValidator;
import javax.validation.Constraint;
@@ -14,7 +15,7 @@
@Target(TYPE)
@Retention(RUNTIME)
@Documented
-@Constraint(validatedBy = {AlgorithmValidator.class})
+@Constraint(validatedBy = {JTIValidator.class})
public @interface ValidateJTI {
String message() default "JTI has been replayed";
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateNotValidBefore.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateNotValidBefore.java
deleted file mode 100644
index 37739dde..00000000
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateNotValidBefore.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.wso2.openbanking.accelerator.identity.app2app.validations.annotations;
-
-import com.wso2.openbanking.accelerator.identity.dcr.validation.AlgorithmValidator;
-
-import javax.validation.Constraint;
-import javax.validation.Payload;
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-@Target(TYPE)
-@Retention(RUNTIME)
-@Documented
-@Constraint(validatedBy = {AlgorithmValidator.class})
-public @interface ValidateNotValidBefore {
- String message() default "JWT not active.";
-
- Class>[] groups() default {};
-
- Class extends Payload>[] payload() default {};
-}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateSignature.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateSignature.java
index 0d9cc9c5..43aa486d 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateSignature.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateSignature.java
@@ -1,5 +1,6 @@
package com.wso2.openbanking.accelerator.identity.app2app.validations.annotations;
+import com.wso2.openbanking.accelerator.identity.app2app.validations.SignatureValidator;
import com.wso2.openbanking.accelerator.identity.dcr.validation.AlgorithmValidator;
import javax.validation.Constraint;
@@ -14,7 +15,7 @@
@Target(TYPE)
@Retention(RUNTIME)
@Documented
-@Constraint(validatedBy = {AlgorithmValidator.class})
+@Constraint(validatedBy = {SignatureValidator.class})
public @interface ValidateSignature {
String message() default "Signature validation Failed.";
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateExpiry.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateTimeliness.java
similarity index 65%
rename from open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateExpiry.java
rename to open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateTimeliness.java
index e7b53349..a288a18f 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateExpiry.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateTimeliness.java
@@ -1,6 +1,6 @@
package com.wso2.openbanking.accelerator.identity.app2app.validations.annotations;
-import com.wso2.openbanking.accelerator.identity.dcr.validation.AlgorithmValidator;
+import com.wso2.openbanking.accelerator.identity.app2app.validations.JwtTokenTimelinessValidator;
import javax.validation.Constraint;
import javax.validation.Payload;
@@ -14,9 +14,9 @@
@Target(TYPE)
@Retention(RUNTIME)
@Documented
-@Constraint(validatedBy = {AlgorithmValidator.class})
-public @interface ValidateExpiry {
- String message() default "JWT Expired";
+@Constraint(validatedBy = {JwtTokenTimelinessValidator.class})
+public @interface ValidateTimeliness {
+ String message() default "JWT token contains invalid time claims.";
Class>[] groups() default {};
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/validationgroups/ValidationOrder.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/validationgroups/ValidationOrder.java
new file mode 100644
index 00000000..3ac9759f
--- /dev/null
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/validationgroups/ValidationOrder.java
@@ -0,0 +1,7 @@
+package com.wso2.openbanking.accelerator.identity.app2app.validations.validationgroups;
+
+import javax.validation.GroupSequence;
+
+@GroupSequence({RequiredParamChecks.class})
+public interface ValidationOrder {
+}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorTest.java
index 7e0d33f4..2e93c927 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorTest.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorTest.java
@@ -49,20 +49,6 @@ public void initiateAuthenticationRequest(){
}
}
- @Test(dataProviderClass = App2AppAuthenticatorTestDataProvider.class,
- dataProvider = "sessionDataKeyProvider")
- public void getAdditionalInfoTest(String sessionDataKey){
- mockRequest = mock(HttpServletRequest.class);
- mockResponse = mock(HttpServletResponse.class);
- try {
- Optional output =
- app2AppAuthenticator.getAdditionalInfo(mockRequest,mockResponse,sessionDataKey);
- assertEquals(output,Optional.empty());
- } catch (AuthenticationFailedException e) {
- throw new RuntimeException(e);
- }
- }
-
@Test(dataProviderClass = App2AppAuthenticatorTestDataProvider.class,
dataProvider = "sessionDataKeyProvider")
public void getContextIdentifierTest(String sessionDataKey){
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/token/validators/MTLSCertificateValidatorTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/token/validators/MTLSCertificateValidatorTest.java
index 8157b4da..b3484b49 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/token/validators/MTLSCertificateValidatorTest.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/token/validators/MTLSCertificateValidatorTest.java
@@ -40,7 +40,7 @@
import static org.testng.Assert.assertEquals;
/**
- *
+ *class for MTLSCertificateValidator Test.
*/
@PrepareForTest({IdentityCommonUtil.class})
@PowerMockIgnore({"jdk.internal.reflect.*"})
From fa0f62f8b4fd6ed17208cea536d3f8d5665678a2 Mon Sep 17 00:00:00 2001
From: ImalshaD
Date: Thu, 9 May 2024 12:32:22 +0530
Subject: [PATCH 143/281] Added MTLSCertificateValidatorTest JavaDoc
---
.../identity/token/validators/MTLSCertificateValidatorTest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/token/validators/MTLSCertificateValidatorTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/token/validators/MTLSCertificateValidatorTest.java
index b3484b49..b1ec9332 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/token/validators/MTLSCertificateValidatorTest.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/token/validators/MTLSCertificateValidatorTest.java
@@ -40,7 +40,7 @@
import static org.testng.Assert.assertEquals;
/**
- *class for MTLSCertificateValidator Test.
+ * class for MTLSCertificateValidator Test.
*/
@PrepareForTest({IdentityCommonUtil.class})
@PowerMockIgnore({"jdk.internal.reflect.*"})
From 003a1fbabc9f744da962037ed0ec3276cfb1d44d Mon Sep 17 00:00:00 2001
From: ImalshaD
Date: Sat, 11 May 2024 05:40:22 +0530
Subject: [PATCH 144/281] Architectural changes reflected.
---
.../accelerator/common/util/JWTUtils.java | 30 +-------
.../app2app/App2AppAuthenticator.java | 34 +++++++--
.../App2AppAuthenticatorConstants.java | 17 +++++
.../exception/SecretValidationException.java | 17 +++++
.../identity/app2app/model/Secret.java | 70 ++++++++++++-------
.../app2app/utils/App2AppAuthUtils.java | 19 ++++-
.../app2app/validations/JTIValidator.java | 46 +++++++++---
.../JwtTokenTimelinessValidator.java | 32 ++++++++-
.../validations/SignatureValidator.java | 55 ++++++++++-----
.../validations/annotations/ValidateJTI.java | 26 ++++++-
.../annotations/ValidateSignature.java | 26 ++++++-
.../annotations/ValidateTimeliness.java | 27 ++++++-
.../validationgroups/RequiredParamChecks.java | 21 ++++++
.../validationgroups/ValidationOrder.java | 22 +++++-
.../validationgroups/ValidityChecks.java | 21 ++++++
.../app2app/App2AppAuthenticatorTest.java | 38 +++++++++-
.../src/test/resources/testng.xml | 5 ++
17 files changed, 411 insertions(+), 95 deletions(-)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/JWTUtils.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/JWTUtils.java
index 5d741702..90f0721b 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/JWTUtils.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/JWTUtils.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
@@ -210,34 +210,6 @@ public static SignedJWT getSignedJWT(String jwtString) throws ParseException {
}
- /**
- * Extracts the JWT claims set from the provided SignedJWT object.
- *
- * @param signedJWT the signedJWT object from which the claims are extracted
- * @return extracted jwt claims set in JWTClaimsSet object
- * @throws ParseException if the signedJWT is corrupted
- */
- public static JWTClaimsSet getJWTClaimsSet(SignedJWT signedJWT) throws ParseException {
-
- return signedJWT.getJWTClaimsSet();
-
- }
-
- /**
- * Retrieves the value of the specified claim from the provided JWTClaimsSet.
- *
- * @param jwtClaimsSet the JWTClaimsSet from which to retrieve the claim value
- * @param claim the name of the claim to retrieve
- * @param the type of the claim value
- * @return the value of the specified claim, or null if the claim is not present
- */
- public static T getClaim(JWTClaimsSet jwtClaimsSet , String claim) {
-
- Object claimObj = jwtClaimsSet.getClaim(claim);
- return (T) claimObj;
-
- }
-
/**
* Validates whether a given JWT is not expired.
*
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticator.java
index 12a7d90b..b5ff26ae 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticator.java
@@ -1,10 +1,28 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package com.wso2.openbanking.accelerator.identity.app2app;
+import com.nimbusds.jwt.SignedJWT;
+import com.wso2.openbanking.accelerator.common.util.JWTUtils;
import com.wso2.openbanking.accelerator.identity.app2app.exception.SecretValidationException;
import com.wso2.openbanking.accelerator.identity.app2app.model.Secret;
import com.wso2.openbanking.accelerator.identity.app2app.utils.App2AppAuthUtils;
-import com.wso2.openbanking.accelerator.identity.cache.IdentityCache;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -14,6 +32,7 @@
import org.wso2.carbon.identity.application.authenticator.push.PushAuthenticator;
import org.wso2.carbon.identity.application.common.model.Property;
+import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
@@ -26,7 +45,6 @@
*/
public class App2AppAuthenticator extends PushAuthenticator {
- private static IdentityCache identityCache;
private static final Log log = LogFactory.getLog(App2AppAuthenticator.class);
private static final long serialVersionUID = -5439464372188473141L;
@@ -51,8 +69,12 @@ protected void processAuthenticationResponse(HttpServletRequest httpServletReque
String jwtString = httpServletRequest.getParameter(App2AppAuthenticatorConstants.SECRET);
try {
- Secret secret = new Secret(jwtString);
- App2AppAuthUtils.getValidationViolations(secret);
+ SignedJWT signedJWT = JWTUtils.getSignedJWT(jwtString);
+ Secret secret = new Secret(signedJWT);
+ String loginHint = secret.getLoginHint();
+ AuthenticatedUser authenticatedUser = App2AppAuthUtils.getAuthenticatedUserFromSubjectIdentifier(loginHint);
+ secret.setAuthenticatedUser(authenticatedUser);
+ App2AppAuthUtils.validateSecret(secret);
AuthenticatedUser user = secret.getAuthenticatedUser();
authenticationContext.setSubject(user);
} catch (SecretValidationException e) {
@@ -61,6 +83,8 @@ protected void processAuthenticationResponse(HttpServletRequest httpServletReque
throw new AuthenticationFailedException("Illegal Argument exception: " + e.getMessage(), e);
} catch (RuntimeException e) {
throw new AuthenticationFailedException("Run Time exception: " + e.getMessage(), e);
+ } catch (ParseException e) {
+ throw new AuthenticationFailedException("Provided JWT for AppValidationJWT is not parsable: " + e.getMessage(), e);
}
}
@@ -82,7 +106,7 @@ public String getContextIdentifier(HttpServletRequest request) {
@Override
protected void initiateAuthenticationRequest(HttpServletRequest request, HttpServletResponse response,
AuthenticationContext context) throws AuthenticationFailedException {
-
+ log.error("Initializing App2App authenticator is not supported.");
throw new AuthenticationFailedException("Mandatory parameter secret null or empty in request.");
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorConstants.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorConstants.java
index aa7a2a04..2fb012b0 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorConstants.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorConstants.java
@@ -1,3 +1,20 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package com.wso2.openbanking.accelerator.identity.app2app;
/**
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/exception/SecretValidationException.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/exception/SecretValidationException.java
index c102dc7a..ae86427d 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/exception/SecretValidationException.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/exception/SecretValidationException.java
@@ -1,3 +1,20 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package com.wso2.openbanking.accelerator.identity.app2app.exception;
import com.wso2.openbanking.accelerator.common.exception.OpenBankingException;
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/Secret.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/Secret.java
index 7d068ee7..535456be 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/Secret.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/Secret.java
@@ -1,9 +1,25 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package com.wso2.openbanking.accelerator.identity.app2app.model;
import com.google.gson.annotations.SerializedName;
import com.nimbusds.jwt.JWTClaimsSet;
import com.nimbusds.jwt.SignedJWT;
-import com.wso2.openbanking.accelerator.common.util.JWTUtils;
import com.wso2.openbanking.accelerator.identity.app2app.App2AppAuthenticatorConstants;
import com.wso2.openbanking.accelerator.identity.app2app.exception.SecretValidationException;
import com.wso2.openbanking.accelerator.identity.app2app.validations.annotations.ValidateJTI;
@@ -13,10 +29,10 @@
import com.wso2.openbanking.accelerator.identity.app2app.validations.validationgroups.ValidityChecks;
import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser;
-import java.text.ParseException;
-import java.util.Date;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
+import java.text.ParseException;
+import java.util.Date;
/**
@@ -40,23 +56,20 @@ public class Secret {
private Date issuedTime;
private SignedJWT signedJWT;
private JWTClaimsSet jwtClaimsSet;
- private String publicKey;
private AuthenticatedUser authenticatedUser;
- public Secret(String jwtString) throws SecretValidationException {
+ public Secret(SignedJWT signedJWT) throws SecretValidationException {
try {
- this.signedJWT = JWTUtils.getSignedJWT(jwtString);
- this.jwtClaimsSet = JWTUtils.getJWTClaimsSet(this.signedJWT);
+ this.signedJWT = signedJWT;
+ this.jwtClaimsSet = signedJWT.getJWTClaimsSet();
this.expirationTime = jwtClaimsSet.getExpirationTime();
this.notValidBefore = jwtClaimsSet.getNotBeforeTime();
this.issuedTime = jwtClaimsSet.getIssueTime();
this.jti = jwtClaimsSet.getJWTID();
- this.deviceId = JWTUtils.getClaim(jwtClaimsSet, App2AppAuthenticatorConstants.DEVICE_IDENTIFIER);
- this.loginHint = JWTUtils.getClaim(jwtClaimsSet, App2AppAuthenticatorConstants.LOGIN_HINT);
- } catch (ParseException e) {
- throw new SecretValidationException("Error while parsing JWT.", e);
- } catch (IllegalArgumentException e) {
+ this.deviceId = getClaim(jwtClaimsSet,App2AppAuthenticatorConstants.DEVICE_IDENTIFIER);
+ this.loginHint = getClaim(jwtClaimsSet,App2AppAuthenticatorConstants.LOGIN_HINT);
+ } catch (IllegalArgumentException | ParseException e) {
throw new SecretValidationException(e.getMessage());
}
@@ -77,7 +90,7 @@ public String getLoginHint() {
public void setLoginHint(String loginHint) {
this.loginHint = loginHint;
}
- @NotNull(message = "Required Parameter exp cannot be null or empty.", groups = RequiredParamChecks.class)
+ @NotNull(message = "Required Parameter exp cannot be null.", groups = RequiredParamChecks.class)
public Date getExpirationTime() {
return expirationTime;
}
@@ -85,7 +98,7 @@ public Date getExpirationTime() {
public void setExpirationTime(Date expirationTime) {
this.expirationTime = expirationTime;
}
- @NotNull(message = "Required Parameter nbf cannot be null or empty.", groups = RequiredParamChecks.class)
+ @NotNull(message = "Required Parameter nbf cannot be null.", groups = RequiredParamChecks.class)
public Date getNotValidBefore() {
return notValidBefore;
}
@@ -95,13 +108,13 @@ public void setNotValidBefore(Date notValidBefore) {
}
@NotBlank(message = "Required Parameter jti cannot be null or empty.", groups = RequiredParamChecks.class)
public String getJti() {
- return jti;
+ return jwtClaimsSet.getJWTID();
}
public void setJti(String jti) {
this.jti = jti;
}
- @NotNull(message = "Required Parameter iat cannot be null or empty.", groups = RequiredParamChecks.class)
+ @NotNull(message = "Required Parameter iat cannot be null.", groups = RequiredParamChecks.class)
public Date getIssuedTime() {
return issuedTime;
}
@@ -109,14 +122,7 @@ public Date getIssuedTime() {
public void setIssuedTime(Date issuedAt) {
this.issuedTime = issuedAt;
}
-
- public String getPublicKey() {
- return publicKey;
- }
-
- public void setPublicKey(String publicKey) {
- this.publicKey = publicKey;
- }
+ @NotNull(message = "Required Parameter signedJWT cannot be null.", groups = RequiredParamChecks.class)
public SignedJWT getSignedJWT() {
return signedJWT;
}
@@ -133,6 +139,7 @@ public void setAuthenticatedUser(AuthenticatedUser authenticatedUser) {
this.authenticatedUser = authenticatedUser;
}
+ @NotNull(message = "Required Parameter jwtClaimsSet cannot be null.", groups = RequiredParamChecks.class)
public JWTClaimsSet getJwtClaimsSet() {
return jwtClaimsSet;
}
@@ -140,5 +147,20 @@ public JWTClaimsSet getJwtClaimsSet() {
public void setJwtClaimsSet(JWTClaimsSet jwtClaimsSet) {
this.jwtClaimsSet = jwtClaimsSet;
}
+
+ /**
+ * Retrieves the value of the specified claim from the provided JWTClaimsSet.
+ *
+ * @param jwtClaimsSet the JWTClaimsSet from which to retrieve the claim value
+ * @param claim the name of the claim to retrieve
+ * @param the type of the claim value
+ * @return the value of the specified claim, or null if the claim is not present
+ */
+ private T getClaim(JWTClaimsSet jwtClaimsSet , String claim) {
+
+ Object claimObj = jwtClaimsSet.getClaim(claim);
+ return (T) claimObj;
+
+ }
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/utils/App2AppAuthUtils.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/utils/App2AppAuthUtils.java
index 99889b01..03e13c16 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/utils/App2AppAuthUtils.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/utils/App2AppAuthUtils.java
@@ -1,3 +1,20 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package com.wso2.openbanking.accelerator.identity.app2app.utils;
import com.wso2.openbanking.accelerator.common.validator.OpenBankingValidator;
@@ -140,7 +157,7 @@ public static String getPublicKey(String deviceID, String userID) throws PushDev
* @param secret Secret object that needs to be validated
* @throws SecretValidationException if validation f
*/
- public static void getValidationViolations(Secret secret) throws SecretValidationException {
+ public static void validateSecret(Secret secret) throws SecretValidationException {
String error = OpenBankingValidator.getInstance().getFirstViolation(secret, ValidationOrder.class);
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JTIValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JTIValidator.java
index 0e8d29fd..ce49f874 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JTIValidator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JTIValidator.java
@@ -1,3 +1,20 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package com.wso2.openbanking.accelerator.identity.app2app.validations;
import com.wso2.openbanking.accelerator.identity.app2app.model.Secret;
@@ -8,36 +25,49 @@
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
+/**
+ * Validator class for validating the JWT ID.
+ */
public class JTIValidator implements ConstraintValidator {
private static IdentityCache identityCache;
+
@Override
public boolean isValid(Secret secret, ConstraintValidatorContext constraintValidatorContext) {
+
String jti = secret.getJti();
return validateJTI(jti);
}
- private boolean validateJTI(String jti){
+ private boolean validateJTI(String jti) {
+
IdentityCacheKey jtiCacheKey = new IdentityCacheKey(jti);
- if (getFromCache(jtiCacheKey) != null){
+
+ if (getFromCache(jtiCacheKey) != null) {
return false;
}
- addToCache(jtiCacheKey,jti);
+
+ //adding to cache to prevent the value from being replayed again
+ addToCache(jtiCacheKey, jti);
return true;
}
- private Object getFromCache(IdentityCacheKey identityCacheKey){
- if (identityCache == null){
+ private Object getFromCache(IdentityCacheKey identityCacheKey) {
+ //Lazy initialization
+ if (identityCache == null) {
identityCache = new IdentityCache();
}
+
return identityCache.getFromCache(identityCacheKey);
}
- private void addToCache(IdentityCacheKey identityCacheKey, Object value){
- if (identityCache == null){
+ private void addToCache(IdentityCacheKey identityCacheKey, Object value) {
+ //Lazy initialization
+ if (identityCache == null) {
identityCache = new IdentityCache();
}
- identityCache.addToCache(identityCacheKey,value);
+
+ identityCache.addToCache(identityCacheKey, value);
}
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JwtTokenTimelinessValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JwtTokenTimelinessValidator.java
index 5fee61da..de1877f1 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JwtTokenTimelinessValidator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JwtTokenTimelinessValidator.java
@@ -1,3 +1,20 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package com.wso2.openbanking.accelerator.identity.app2app.validations;
import com.nimbusds.jwt.JWTClaimsSet;
@@ -10,19 +27,30 @@
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
+/**
+ * Validator class for validating the timeliness of a JWT.
+ * Validates the expiry.
+ * Validates the nbf.
+ */
public class JwtTokenTimelinessValidator implements ConstraintValidator {
private static final Log log = LogFactory.getLog(JwtTokenTimelinessValidator.class);
@Override
public boolean isValid(Secret secret, ConstraintValidatorContext constraintValidatorContext) {
+
JWTClaimsSet jwtClaimsSet = secret.getJwtClaimsSet();
- if (!JWTUtils.validateExpiryTime(jwtClaimsSet)){
+
+ //Validating the exp of the JWT
+ if (!JWTUtils.validateExpiryTime(jwtClaimsSet)) {
log.error("JWT Expired.");
return false;
}
- if (!JWTUtils.validateNotValidBefore(jwtClaimsSet)){
+
+ //Validating the nbf of the JWT
+ if (!JWTUtils.validateNotValidBefore(jwtClaimsSet)) {
log.error("JWT is not active.");
return false;
}
+
return true;
}
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/SignatureValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/SignatureValidator.java
index 49dc848b..a64d4c25 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/SignatureValidator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/SignatureValidator.java
@@ -1,3 +1,20 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package com.wso2.openbanking.accelerator.identity.app2app.validations;
import com.nimbusds.jose.JOSEException;
@@ -14,56 +31,62 @@
import org.wso2.carbon.user.api.UserRealm;
import org.wso2.carbon.user.api.UserStoreException;
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * Validator class for validating the signature of a JWT.
+ */
// TODO: change the name of this implementation
public class SignatureValidator implements ConstraintValidator {
private static final Log log = LogFactory.getLog(SignatureValidator.class);
private String algorithm;
@Override
public void initialize(ValidateSignature validateSignature) {
+
this.algorithm = validateSignature.algorithm();
}
@Override
public boolean isValid(Secret secret, ConstraintValidatorContext constraintValidatorContext) {
+
try {
+
SignedJWT signedJWT = secret.getSignedJWT();
- String loginHint = secret.getLoginHint();
String deviceID = secret.getDeviceId();
- AuthenticatedUser authenticatedUser =
- App2AppAuthUtils.getAuthenticatedUserFromSubjectIdentifier(loginHint);
- secret.setAuthenticatedUser(authenticatedUser);
+ AuthenticatedUser authenticatedUser = secret.getAuthenticatedUser();
UserRealm userRealm = App2AppAuthUtils.getUserRealm(authenticatedUser);
- String userID = App2AppAuthUtils.getUserIdFromUsername(authenticatedUser.getUserName(),userRealm);
- String publicKey = App2AppAuthUtils.getPublicKey(deviceID,userID);
- boolean isSignatureValid = JWTUtils.validateJWTSignature(signedJWT,publicKey,algorithm);
- if (!isSignatureValid){
+ String userID = App2AppAuthUtils.getUserIdFromUsername(authenticatedUser.getUserName(), userRealm);
+ String publicKey = App2AppAuthUtils.getPublicKey(deviceID, userID);
+
+ if (!JWTUtils.validateJWTSignature(signedJWT, publicKey, algorithm)) {
log.error("Signature can't be verified with registered public key.");
return false;
}
} catch (UserStoreException e) {
- log.error("Error while creating authenticated user.",e);
+ log.error("Error while creating authenticated user.", e);
return false;
} catch (PushDeviceHandlerServerException e) {
- log.error("Error occurred push device handler service.",e);
+ log.error("Error occurred push device handler service.", e);
return false;
} catch (PushDeviceHandlerClientException e) {
- log.error("Push Device handler client.",e);
+ log.error("Push Device handler client.", e);
return false;
} catch (NoSuchAlgorithmException e) {
- log.error("No such algorithm found -"+algorithm+".",e);
+ log.error("No such algorithm found -" + algorithm + ".", e);
return false;
} catch (InvalidKeySpecException e) {
- log.error("Invalid key spec.",e);
+ log.error("Invalid key spec.", e);
return false;
} catch (JOSEException e) {
- log.error("JOSE exception",e);
+ log.error("JOSE exception", e);
return false;
}
return true;
+
}
}
+
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateJTI.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateJTI.java
index b0bd7562..9264f12f 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateJTI.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateJTI.java
@@ -1,17 +1,37 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package com.wso2.openbanking.accelerator.identity.app2app.validations.annotations;
import com.wso2.openbanking.accelerator.identity.app2app.validations.JTIValidator;
-import com.wso2.openbanking.accelerator.identity.dcr.validation.AlgorithmValidator;
-import javax.validation.Constraint;
-import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+import javax.validation.Constraint;
+import javax.validation.Payload;
+
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
+/**
+ * Annotation class for validating JWT ID.
+ */
@Target(TYPE)
@Retention(RUNTIME)
@Documented
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateSignature.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateSignature.java
index 43aa486d..eee37bb4 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateSignature.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateSignature.java
@@ -1,17 +1,37 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package com.wso2.openbanking.accelerator.identity.app2app.validations.annotations;
import com.wso2.openbanking.accelerator.identity.app2app.validations.SignatureValidator;
-import com.wso2.openbanking.accelerator.identity.dcr.validation.AlgorithmValidator;
-import javax.validation.Constraint;
-import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+import javax.validation.Constraint;
+import javax.validation.Payload;
+
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
+/**
+ * Annotation class for validating JWT Signature.
+ */
@Target(TYPE)
@Retention(RUNTIME)
@Documented
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateTimeliness.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateTimeliness.java
index a288a18f..68f0ee20 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateTimeliness.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateTimeliness.java
@@ -1,16 +1,39 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package com.wso2.openbanking.accelerator.identity.app2app.validations.annotations;
import com.wso2.openbanking.accelerator.identity.app2app.validations.JwtTokenTimelinessValidator;
-import javax.validation.Constraint;
-import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+import javax.validation.Constraint;
+import javax.validation.Payload;
+
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
+/**
+ * Annotation class for validating JWT Timeliness of JWT.
+ * Validates whether a JWT is expired.
+ * Validated whether a JWT is active.
+ */
@Target(TYPE)
@Retention(RUNTIME)
@Documented
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/validationgroups/RequiredParamChecks.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/validationgroups/RequiredParamChecks.java
index a8194541..aac79e5b 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/validationgroups/RequiredParamChecks.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/validationgroups/RequiredParamChecks.java
@@ -1,4 +1,25 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package com.wso2.openbanking.accelerator.identity.app2app.validations.validationgroups;
+/**
+ * Interface for grouping the validation annotations.
+ * Groups the validations for required parameters
+ */
public interface RequiredParamChecks {
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/validationgroups/ValidationOrder.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/validationgroups/ValidationOrder.java
index 3ac9759f..89bf2c6a 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/validationgroups/ValidationOrder.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/validationgroups/ValidationOrder.java
@@ -1,7 +1,27 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package com.wso2.openbanking.accelerator.identity.app2app.validations.validationgroups;
import javax.validation.GroupSequence;
-@GroupSequence({RequiredParamChecks.class})
+/**
+ * Class to define the order of execution for the hibernate validation groups.
+ */
+@GroupSequence({RequiredParamChecks.class, ValidityChecks.class})
public interface ValidationOrder {
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/validationgroups/ValidityChecks.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/validationgroups/ValidityChecks.java
index e9dbc5b3..cf277ec9 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/validationgroups/ValidityChecks.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/validationgroups/ValidityChecks.java
@@ -1,4 +1,25 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package com.wso2.openbanking.accelerator.identity.app2app.validations.validationgroups;
+/**
+ * Interface for grouping the validation annotations.
+ * Groups the validations for the validity of a JWT
+ */
public interface ValidityChecks {
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorTest.java
index 2e93c927..ad29e619 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorTest.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorTest.java
@@ -1,5 +1,6 @@
package com.wso2.openbanking.accelerator.identity.app2app;
+import com.wso2.openbanking.accelerator.identity.app2app.utils.App2AppAuthUtils;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext;
@@ -7,7 +8,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import java.util.Optional;
import static org.powermock.api.mockito.PowerMockito.mock;
import static org.powermock.api.mockito.PowerMockito.when;
@@ -23,6 +23,22 @@ public class App2AppAuthenticatorTest {
public void setup(){
app2AppAuthenticator = new App2AppAuthenticator();
}
+
+ @Test
+ public void testGetName() {
+ App2AppAuthenticator authenticator = new App2AppAuthenticator();
+ String expectedName = App2AppAuthenticatorConstants.AUTHENTICATOR_NAME;
+ String actualName = authenticator.getName();
+ assertEquals(actualName, expectedName, "Expected and actual names should match");
+ }
+
+ @Test
+ public void testGetFriendlyName() {
+ App2AppAuthenticator authenticator = new App2AppAuthenticator();
+ String expectedFriendlyName = App2AppAuthenticatorConstants.AUTHENTICATOR_FRIENDLY_NAME;
+ String actualFriendlyName = authenticator.getFriendlyName();
+ assertEquals(actualFriendlyName, expectedFriendlyName, "Expected and actual friendly names should match");
+ }
@Test(dataProviderClass =App2AppAuthenticatorTestDataProvider.class ,
dataProvider = "UsernameAndPasswordProvider")
public void canHandleTestCase(String secret, String expected) {
@@ -57,4 +73,24 @@ public void getContextIdentifierTest(String sessionDataKey){
String output = app2AppAuthenticator.getContextIdentifier(mockRequest);
assertEquals(sessionDataKey,output);
}
+
+ @Test(expectedExceptions = AuthenticationFailedException.class)
+ public void testProcessAuthenticationResponse_InvalidJWT(String jwtString) throws AuthenticationFailedException {
+ // Mock HttpServletRequest, HttpServletResponse, and AuthenticationContext
+ HttpServletRequest requestMock = mock(HttpServletRequest.class);
+ HttpServletResponse responseMock = mock(HttpServletResponse.class);
+ AuthenticationContext authContextMock = mock(AuthenticationContext.class);
+
+ // Set up mock behavior for HttpServletRequest
+ when(requestMock.getParameter(App2AppAuthenticatorConstants.SECRET)).thenReturn(jwtString);
+ // Call the method under test, expecting an exception
+ try {
+ App2AppAuthenticator authenticator = new App2AppAuthenticator();
+ authenticator.processAuthenticationResponse(requestMock, responseMock, authContextMock);
+ }catch (AuthenticationFailedException e) {
+ throw e;
+ }catch (RuntimeException e) {
+ System.out.println(e.getMessage());
+ }
+ }
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/resources/testng.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/resources/testng.xml
index 0f4e00ef..56b57e12 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/resources/testng.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/resources/testng.xml
@@ -130,4 +130,9 @@
+
+
+
+
+
From 473b48ee5a8ece26e6655f338badc62321747323 Mon Sep 17 00:00:00 2001
From: ImalshaD
Date: Sat, 11 May 2024 05:57:30 +0530
Subject: [PATCH 145/281] Model name refactored.
---
.../identity/app2app/App2AppAuthenticator.java | 12 ++++++------
.../app2app/exception/SecretValidationException.java | 2 +-
.../model/{Secret.java => AppAuthValidationJWT.java} | 6 +++---
.../identity/app2app/utils/App2AppAuthUtils.java | 10 +++++-----
.../identity/app2app/validations/JTIValidator.java | 8 ++++----
.../validations/JwtTokenTimelinessValidator.java | 8 ++++----
.../app2app/validations/SignatureValidator.java | 12 ++++++------
7 files changed, 29 insertions(+), 29 deletions(-)
rename open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/{Secret.java => AppAuthValidationJWT.java} (97%)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticator.java
index b5ff26ae..df1636d7 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticator.java
@@ -21,7 +21,7 @@
import com.nimbusds.jwt.SignedJWT;
import com.wso2.openbanking.accelerator.common.util.JWTUtils;
import com.wso2.openbanking.accelerator.identity.app2app.exception.SecretValidationException;
-import com.wso2.openbanking.accelerator.identity.app2app.model.Secret;
+import com.wso2.openbanking.accelerator.identity.app2app.model.AppAuthValidationJWT;
import com.wso2.openbanking.accelerator.identity.app2app.utils.App2AppAuthUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
@@ -70,12 +70,12 @@ protected void processAuthenticationResponse(HttpServletRequest httpServletReque
String jwtString = httpServletRequest.getParameter(App2AppAuthenticatorConstants.SECRET);
try {
SignedJWT signedJWT = JWTUtils.getSignedJWT(jwtString);
- Secret secret = new Secret(signedJWT);
- String loginHint = secret.getLoginHint();
+ AppAuthValidationJWT appAuthValidationJWT = new AppAuthValidationJWT(signedJWT);
+ String loginHint = appAuthValidationJWT.getLoginHint();
AuthenticatedUser authenticatedUser = App2AppAuthUtils.getAuthenticatedUserFromSubjectIdentifier(loginHint);
- secret.setAuthenticatedUser(authenticatedUser);
- App2AppAuthUtils.validateSecret(secret);
- AuthenticatedUser user = secret.getAuthenticatedUser();
+ appAuthValidationJWT.setAuthenticatedUser(authenticatedUser);
+ App2AppAuthUtils.validateSecret(appAuthValidationJWT);
+ AuthenticatedUser user = appAuthValidationJWT.getAuthenticatedUser();
authenticationContext.setSubject(user);
} catch (SecretValidationException e) {
throw new AuthenticationFailedException(e.getMessage());
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/exception/SecretValidationException.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/exception/SecretValidationException.java
index ae86427d..3abce747 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/exception/SecretValidationException.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/exception/SecretValidationException.java
@@ -20,7 +20,7 @@
import com.wso2.openbanking.accelerator.common.exception.OpenBankingException;
/**
- * Secret Object Validation Exception.
+ * AppAuthValidationJWT Object Validation Exception.
*/
public class SecretValidationException extends OpenBankingException {
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/Secret.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/AppAuthValidationJWT.java
similarity index 97%
rename from open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/Secret.java
rename to open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/AppAuthValidationJWT.java
index 535456be..85f557ff 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/Secret.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/AppAuthValidationJWT.java
@@ -36,12 +36,12 @@
/**
- * Model class for App2App Auth Secret.
+ * Model class for App2App Auth AppAuthValidationJWT.
*/
@ValidateJTI(groups = ValidityChecks.class)
@ValidateSignature(algorithm = App2AppAuthenticatorConstants.SIGNING_ALGORITHM, groups = ValidityChecks.class)
@ValidateTimeliness(groups = ValidityChecks.class)
-public class Secret {
+public class AppAuthValidationJWT {
@SerializedName("did")
private String deviceId;
@SerializedName("loginHint")
@@ -58,7 +58,7 @@ public class Secret {
private JWTClaimsSet jwtClaimsSet;
private AuthenticatedUser authenticatedUser;
- public Secret(SignedJWT signedJWT) throws SecretValidationException {
+ public AppAuthValidationJWT(SignedJWT signedJWT) throws SecretValidationException {
try {
this.signedJWT = signedJWT;
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/utils/App2AppAuthUtils.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/utils/App2AppAuthUtils.java
index 03e13c16..04cdf035 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/utils/App2AppAuthUtils.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/utils/App2AppAuthUtils.java
@@ -19,7 +19,7 @@
import com.wso2.openbanking.accelerator.common.validator.OpenBankingValidator;
import com.wso2.openbanking.accelerator.identity.app2app.exception.SecretValidationException;
-import com.wso2.openbanking.accelerator.identity.app2app.model.Secret;
+import com.wso2.openbanking.accelerator.identity.app2app.model.AppAuthValidationJWT;
import com.wso2.openbanking.accelerator.identity.app2app.validations.validationgroups.ValidationOrder;
import com.wso2.openbanking.accelerator.identity.internal.IdentityExtensionsDataHolder;
import org.apache.commons.lang.StringUtils;
@@ -152,14 +152,14 @@ public static String getPublicKey(String deviceID, String userID) throws PushDev
}
/**
- * Validator util to validate Secret model for given validationOrder.
+ * Validator util to validate AppAuthValidationJWT model for given validationOrder.
*
- * @param secret Secret object that needs to be validated
+ * @param appAuthValidationJWT AppAuthValidationJWT object that needs to be validated
* @throws SecretValidationException if validation f
*/
- public static void validateSecret(Secret secret) throws SecretValidationException {
+ public static void validateSecret(AppAuthValidationJWT appAuthValidationJWT) throws SecretValidationException {
- String error = OpenBankingValidator.getInstance().getFirstViolation(secret, ValidationOrder.class);
+ String error = OpenBankingValidator.getInstance().getFirstViolation(appAuthValidationJWT, ValidationOrder.class);
//if there is a validation violation convert it to secretValidationException
if (error != null) {
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JTIValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JTIValidator.java
index ce49f874..ff61f7ad 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JTIValidator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JTIValidator.java
@@ -17,7 +17,7 @@
*/
package com.wso2.openbanking.accelerator.identity.app2app.validations;
-import com.wso2.openbanking.accelerator.identity.app2app.model.Secret;
+import com.wso2.openbanking.accelerator.identity.app2app.model.AppAuthValidationJWT;
import com.wso2.openbanking.accelerator.identity.app2app.validations.annotations.ValidateJTI;
import com.wso2.openbanking.accelerator.identity.cache.IdentityCache;
import com.wso2.openbanking.accelerator.identity.cache.IdentityCacheKey;
@@ -28,13 +28,13 @@
/**
* Validator class for validating the JWT ID.
*/
-public class JTIValidator implements ConstraintValidator {
+public class JTIValidator implements ConstraintValidator {
private static IdentityCache identityCache;
@Override
- public boolean isValid(Secret secret, ConstraintValidatorContext constraintValidatorContext) {
+ public boolean isValid(AppAuthValidationJWT appAuthValidationJWT, ConstraintValidatorContext constraintValidatorContext) {
- String jti = secret.getJti();
+ String jti = appAuthValidationJWT.getJti();
return validateJTI(jti);
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JwtTokenTimelinessValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JwtTokenTimelinessValidator.java
index de1877f1..4d454243 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JwtTokenTimelinessValidator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JwtTokenTimelinessValidator.java
@@ -19,7 +19,7 @@
import com.nimbusds.jwt.JWTClaimsSet;
import com.wso2.openbanking.accelerator.common.util.JWTUtils;
-import com.wso2.openbanking.accelerator.identity.app2app.model.Secret;
+import com.wso2.openbanking.accelerator.identity.app2app.model.AppAuthValidationJWT;
import com.wso2.openbanking.accelerator.identity.app2app.validations.annotations.ValidateTimeliness;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -32,12 +32,12 @@
* Validates the expiry.
* Validates the nbf.
*/
-public class JwtTokenTimelinessValidator implements ConstraintValidator {
+public class JwtTokenTimelinessValidator implements ConstraintValidator {
private static final Log log = LogFactory.getLog(JwtTokenTimelinessValidator.class);
@Override
- public boolean isValid(Secret secret, ConstraintValidatorContext constraintValidatorContext) {
+ public boolean isValid(AppAuthValidationJWT appAuthValidationJWT, ConstraintValidatorContext constraintValidatorContext) {
- JWTClaimsSet jwtClaimsSet = secret.getJwtClaimsSet();
+ JWTClaimsSet jwtClaimsSet = appAuthValidationJWT.getJwtClaimsSet();
//Validating the exp of the JWT
if (!JWTUtils.validateExpiryTime(jwtClaimsSet)) {
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/SignatureValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/SignatureValidator.java
index a64d4c25..7fe8bba2 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/SignatureValidator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/SignatureValidator.java
@@ -20,7 +20,7 @@
import com.nimbusds.jose.JOSEException;
import com.nimbusds.jwt.SignedJWT;
import com.wso2.openbanking.accelerator.common.util.JWTUtils;
-import com.wso2.openbanking.accelerator.identity.app2app.model.Secret;
+import com.wso2.openbanking.accelerator.identity.app2app.model.AppAuthValidationJWT;
import com.wso2.openbanking.accelerator.identity.app2app.utils.App2AppAuthUtils;
import com.wso2.openbanking.accelerator.identity.app2app.validations.annotations.ValidateSignature;
import org.apache.commons.logging.Log;
@@ -40,7 +40,7 @@
* Validator class for validating the signature of a JWT.
*/
// TODO: change the name of this implementation
-public class SignatureValidator implements ConstraintValidator {
+public class SignatureValidator implements ConstraintValidator {
private static final Log log = LogFactory.getLog(SignatureValidator.class);
private String algorithm;
@Override
@@ -51,13 +51,13 @@ public void initialize(ValidateSignature validateSignature) {
}
@Override
- public boolean isValid(Secret secret, ConstraintValidatorContext constraintValidatorContext) {
+ public boolean isValid(AppAuthValidationJWT appAuthValidationJWT, ConstraintValidatorContext constraintValidatorContext) {
try {
- SignedJWT signedJWT = secret.getSignedJWT();
- String deviceID = secret.getDeviceId();
- AuthenticatedUser authenticatedUser = secret.getAuthenticatedUser();
+ SignedJWT signedJWT = appAuthValidationJWT.getSignedJWT();
+ String deviceID = appAuthValidationJWT.getDeviceId();
+ AuthenticatedUser authenticatedUser = appAuthValidationJWT.getAuthenticatedUser();
UserRealm userRealm = App2AppAuthUtils.getUserRealm(authenticatedUser);
String userID = App2AppAuthUtils.getUserIdFromUsername(authenticatedUser.getUserName(), userRealm);
String publicKey = App2AppAuthUtils.getPublicKey(deviceID, userID);
From 3ecb07f4b10066ba700e1b0e5121d9e851cf8b61 Mon Sep 17 00:00:00 2001
From: ImalshaD
Date: Sun, 12 May 2024 23:22:43 +0530
Subject: [PATCH 146/281] Architecture modified to reduce coupling in
validators and AuthUtils.
---
.../accelerator/common/util/JWTUtils.java | 12 +--
.../app2app/App2AppAuthenticator.java | 64 +++++++++++----
.../App2AppAuthenticatorConstants.java | 13 ++-
...ption.java => JWTValidationException.java} | 6 +-
.../app2app/model/AppAuthValidationJWT.java | 81 +++++++++----------
.../model/AppAuthValidationJWTConstants.java | 12 +++
.../app2app/utils/App2AppAuthUtils.java | 22 ++---
.../JwtTokenTimelinessValidator.java | 28 ++++---
....java => PublicKeySignatureValidator.java} | 38 ++-------
.../annotations/ValidateSignature.java | 6 +-
...Order.java => App2AppValidationOrder.java} | 2 +-
.../app2app/App2AppAuthenticatorTest.java | 5 +-
12 files changed, 165 insertions(+), 124 deletions(-)
rename open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/exception/{SecretValidationException.java => JWTValidationException.java} (83%)
create mode 100644 open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/AppAuthValidationJWTConstants.java
rename open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/{SignatureValidator.java => PublicKeySignatureValidator.java} (53%)
rename open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/validationgroups/{ValidationOrder.java => App2AppValidationOrder.java} (95%)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/JWTUtils.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/JWTUtils.java
index 90f0721b..94bac827 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/JWTUtils.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/JWTUtils.java
@@ -182,7 +182,7 @@ public static boolean isJWT(String jwtString) {
return true;
} catch (ParseException e) {
if (log.isDebugEnabled()) {
- log.debug("Provided token identifier is not a parsable JWT.", e);
+ log.debug("Provided JWT is not a parsable.", e);
}
return false;
}
@@ -213,11 +213,12 @@ public static SignedJWT getSignedJWT(String jwtString) throws ParseException {
/**
* Validates whether a given JWT is not expired.
*
- * @param jwtClaimsSet jwt claims set of the jwt that needs to validated
+ * @param signedJWT the signed jwt that needs to validated
* @return true if the jwt is not expired
*/
- public static boolean validateExpiryTime(JWTClaimsSet jwtClaimsSet) {
+ public static boolean validateExpiryTime(SignedJWT signedJWT) throws ParseException {
+ JWTClaimsSet jwtClaimsSet = signedJWT.getJWTClaimsSet();
Date expirationTime = jwtClaimsSet.getExpirationTime();
if (expirationTime != null) {
long timeStampSkewMillis = DEFAULT_TIME_SKEW_IN_SECONDS * 1000;
@@ -233,11 +234,12 @@ public static boolean validateExpiryTime(JWTClaimsSet jwtClaimsSet) {
/**
* Validates whether a given JWT is active.
*
- * @param jwtClaimsSet jwt claims set of the jwt that needs to validated
+ * @param signedJWT the signed jwt that needs to validated
* @return true if the jwt is active
*/
- public static boolean validateNotValidBefore(JWTClaimsSet jwtClaimsSet) {
+ public static boolean validateNotValidBefore(SignedJWT signedJWT) throws ParseException {
+ JWTClaimsSet jwtClaimsSet = signedJWT.getJWTClaimsSet();
Date notBeforeTime = jwtClaimsSet.getNotBeforeTime();
if (notBeforeTime != null) {
long timeStampSkewMillis = DEFAULT_TIME_SKEW_IN_SECONDS * 1000;
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticator.java
index df1636d7..b136e568 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticator.java
@@ -20,7 +20,7 @@
import com.nimbusds.jwt.SignedJWT;
import com.wso2.openbanking.accelerator.common.util.JWTUtils;
-import com.wso2.openbanking.accelerator.identity.app2app.exception.SecretValidationException;
+import com.wso2.openbanking.accelerator.identity.app2app.exception.JWTValidationException;
import com.wso2.openbanking.accelerator.identity.app2app.model.AppAuthValidationJWT;
import com.wso2.openbanking.accelerator.identity.app2app.utils.App2AppAuthUtils;
import org.apache.commons.lang.StringUtils;
@@ -30,7 +30,11 @@
import org.wso2.carbon.identity.application.authentication.framework.exception.AuthenticationFailedException;
import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser;
import org.wso2.carbon.identity.application.authenticator.push.PushAuthenticator;
+import org.wso2.carbon.identity.application.authenticator.push.device.handler.exception.PushDeviceHandlerClientException;
+import org.wso2.carbon.identity.application.authenticator.push.device.handler.exception.PushDeviceHandlerServerException;
import org.wso2.carbon.identity.application.common.model.Property;
+import org.wso2.carbon.user.api.UserRealm;
+import org.wso2.carbon.user.api.UserStoreException;
import java.text.ParseException;
import java.util.ArrayList;
@@ -67,24 +71,37 @@ protected void processAuthenticationResponse(HttpServletRequest httpServletReque
AuthenticationContext authenticationContext)
throws AuthenticationFailedException {
- String jwtString = httpServletRequest.getParameter(App2AppAuthenticatorConstants.SECRET);
+ String jwtString = httpServletRequest.getParameter(App2AppAuthenticatorConstants.AppAuthValidationJWTIdentifier);
try {
SignedJWT signedJWT = JWTUtils.getSignedJWT(jwtString);
AppAuthValidationJWT appAuthValidationJWT = new AppAuthValidationJWT(signedJWT);
String loginHint = appAuthValidationJWT.getLoginHint();
- AuthenticatedUser authenticatedUser = App2AppAuthUtils.getAuthenticatedUserFromSubjectIdentifier(loginHint);
- appAuthValidationJWT.setAuthenticatedUser(authenticatedUser);
+ String deviceID = appAuthValidationJWT.getDeviceId();
+ AuthenticatedUser userToBeAuthenticated = App2AppAuthUtils.getAuthenticatedUserFromSubjectIdentifier(loginHint);
+ String publicKey = getPublicKeyByDeviceID(deviceID,userToBeAuthenticated);
+ appAuthValidationJWT.setPublicKey(publicKey);
+ appAuthValidationJWT.setSigningAlgorithm(App2AppAuthenticatorConstants.SIGNING_ALGORITHM);
+ /*
+ if validations are failed it will throw a JWTValidationException and flow will be interrupted.
+ Hence, user Authentication will fail.
+ */
App2AppAuthUtils.validateSecret(appAuthValidationJWT);
- AuthenticatedUser user = appAuthValidationJWT.getAuthenticatedUser();
- authenticationContext.setSubject(user);
- } catch (SecretValidationException e) {
- throw new AuthenticationFailedException(e.getMessage());
+ //If the flow is not interrupted user will be authenticated.
+ authenticationContext.setSubject(userToBeAuthenticated);
+ } catch (JWTValidationException e) {
+ throw new AuthenticationFailedException(App2AppAuthenticatorConstants.JWT_VALIDATION_EXCEPTION_MESSAGE + e.getMessage());
} catch (IllegalArgumentException e) {
- throw new AuthenticationFailedException("Illegal Argument exception: " + e.getMessage(), e);
+ throw new AuthenticationFailedException(App2AppAuthenticatorConstants.ILLEGAL_ARGUMENT_EXCEPTION_MESSAGE + e.getMessage(), e);
} catch (RuntimeException e) {
- throw new AuthenticationFailedException("Run Time exception: " + e.getMessage(), e);
+ throw new AuthenticationFailedException(App2AppAuthenticatorConstants.RUNTIME_EXCEPTION_MESSAGE + e.getMessage(), e);
} catch (ParseException e) {
- throw new AuthenticationFailedException("Provided JWT for AppValidationJWT is not parsable: " + e.getMessage(), e);
+ throw new AuthenticationFailedException(App2AppAuthenticatorConstants.PARSE_EXCEPTION_MESSAGE + e.getMessage(), e);
+ } catch (PushDeviceHandlerServerException e) {
+ throw new AuthenticationFailedException(App2AppAuthenticatorConstants.PUSH_DEVICE_HANDLER_SERVER_EXCEPTION_MESSAGE, e);
+ } catch (UserStoreException e) {
+ throw new AuthenticationFailedException(App2AppAuthenticatorConstants.USER_STORE_EXCEPTION_MESSAGE, e);
+ } catch (PushDeviceHandlerClientException e) {
+ throw new AuthenticationFailedException(App2AppAuthenticatorConstants.PUSH_DEVICE_HANDLER_CLIENT_EXCEPTION_MESSAGE, e);
}
}
@@ -92,7 +109,7 @@ protected void processAuthenticationResponse(HttpServletRequest httpServletReque
@Override
public boolean canHandle(HttpServletRequest httpServletRequest) {
- return !StringUtils.isBlank(httpServletRequest.getParameter(App2AppAuthenticatorConstants.SECRET));
+ return !StringUtils.isBlank(httpServletRequest.getParameter(App2AppAuthenticatorConstants.AppAuthValidationJWTIdentifier));
}
@@ -106,8 +123,8 @@ public String getContextIdentifier(HttpServletRequest request) {
@Override
protected void initiateAuthenticationRequest(HttpServletRequest request, HttpServletResponse response,
AuthenticationContext context) throws AuthenticationFailedException {
- log.error("Initializing App2App authenticator is not supported.");
- throw new AuthenticationFailedException("Mandatory parameter secret null or empty in request.");
+ log.error(App2AppAuthenticatorConstants.INITIALIZATION_ERROR_MESSAGE);
+ throw new AuthenticationFailedException(App2AppAuthenticatorConstants.MANDATORY_PARAMETER_ERROR_MESSAGE);
}
@@ -127,5 +144,24 @@ public List getConfigurationProperties() {
return configProperties;
}
+
+ /**
+ * Retrieves the public key associated with a device and user.
+ *
+ * @param deviceID The identifier of the device for which the public key is requested.
+ * @param authenticatedUser the authenticated user for this request
+ * @return The public key associated with the specified device and user.
+ * @throws UserStoreException If an error occurs while accessing user store.
+ * @throws PushDeviceHandlerServerException If an error occurs on the server side of the push device handler.
+ * @throws PushDeviceHandlerClientException If an error occurs on the client side of the push device handler.
+ */
+ private String getPublicKeyByDeviceID(String deviceID, AuthenticatedUser authenticatedUser) throws UserStoreException,
+ PushDeviceHandlerServerException, PushDeviceHandlerClientException {
+
+ UserRealm userRealm = App2AppAuthUtils.getUserRealm(authenticatedUser);
+ String userID = App2AppAuthUtils.getUserIdFromUsername(authenticatedUser.getUserName(), userRealm);
+ return App2AppAuthUtils.getPublicKey(deviceID, userID);
+
+ }
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorConstants.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorConstants.java
index 2fb012b0..4be86e80 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorConstants.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorConstants.java
@@ -30,13 +30,20 @@ public class App2AppAuthenticatorConstants {
public static final String SCOPE = "scope";
public static final String APPLICATION = "application";
- public static final String LOGIN_HINT = "loginHint";
- public static final String DEVICE_IDENTIFIER = "did";
public static final String SIGNING_ALGORITHM = "RSA";
- public static final String SECRET = "secret";
+ public static final String AppAuthValidationJWTIdentifier = "secret";
public static final String IS_ERROR = "isError";
public static final String ERROR = "error";
public static final String SESSION_DATA_KEY = "sessionDataKey";
+ public static final String JWT_VALIDATION_EXCEPTION_MESSAGE = "JWT validation exception: ";
+ public static final String ILLEGAL_ARGUMENT_EXCEPTION_MESSAGE = "Illegal argument exception: ";
+ public static final String RUNTIME_EXCEPTION_MESSAGE = "Runtime exception: ";
+ public static final String PARSE_EXCEPTION_MESSAGE = "Provided JWT for AppValidationJWT is not parsable: ";
+ public static final String PUSH_DEVICE_HANDLER_SERVER_EXCEPTION_MESSAGE = "Error occurred in push device handler service.";
+ public static final String USER_STORE_EXCEPTION_MESSAGE = "Error while creating authenticated user.";
+ public static final String PUSH_DEVICE_HANDLER_CLIENT_EXCEPTION_MESSAGE = "Error occurred in Push Device handler client.";
+ public static final String INITIALIZATION_ERROR_MESSAGE = "Initializing App2App authenticator is not supported.";
+ public static final String MANDATORY_PARAMETER_ERROR_MESSAGE = "Mandatory parameter secret null or empty in request.";
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/exception/SecretValidationException.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/exception/JWTValidationException.java
similarity index 83%
rename from open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/exception/SecretValidationException.java
rename to open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/exception/JWTValidationException.java
index 3abce747..e64a7b99 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/exception/SecretValidationException.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/exception/JWTValidationException.java
@@ -22,16 +22,16 @@
/**
* AppAuthValidationJWT Object Validation Exception.
*/
-public class SecretValidationException extends OpenBankingException {
+public class JWTValidationException extends OpenBankingException {
private static final long serialVersionUID = -2572459527308720228L;
- public SecretValidationException(String message) {
+ public JWTValidationException(String message) {
super(message);
}
- public SecretValidationException(String message, Throwable e) {
+ public JWTValidationException(String message, Throwable e) {
super(message, e);
}
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/AppAuthValidationJWT.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/AppAuthValidationJWT.java
index 85f557ff..33ce1bec 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/AppAuthValidationJWT.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/AppAuthValidationJWT.java
@@ -20,14 +20,12 @@
import com.google.gson.annotations.SerializedName;
import com.nimbusds.jwt.JWTClaimsSet;
import com.nimbusds.jwt.SignedJWT;
-import com.wso2.openbanking.accelerator.identity.app2app.App2AppAuthenticatorConstants;
-import com.wso2.openbanking.accelerator.identity.app2app.exception.SecretValidationException;
+import com.wso2.openbanking.accelerator.identity.app2app.exception.JWTValidationException;
import com.wso2.openbanking.accelerator.identity.app2app.validations.annotations.ValidateJTI;
import com.wso2.openbanking.accelerator.identity.app2app.validations.annotations.ValidateSignature;
import com.wso2.openbanking.accelerator.identity.app2app.validations.annotations.ValidateTimeliness;
import com.wso2.openbanking.accelerator.identity.app2app.validations.validationgroups.RequiredParamChecks;
import com.wso2.openbanking.accelerator.identity.app2app.validations.validationgroups.ValidityChecks;
-import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
@@ -39,43 +37,40 @@
* Model class for App2App Auth AppAuthValidationJWT.
*/
@ValidateJTI(groups = ValidityChecks.class)
-@ValidateSignature(algorithm = App2AppAuthenticatorConstants.SIGNING_ALGORITHM, groups = ValidityChecks.class)
+@ValidateSignature(groups = ValidityChecks.class)
@ValidateTimeliness(groups = ValidityChecks.class)
public class AppAuthValidationJWT {
- @SerializedName("did")
+ @SerializedName(AppAuthValidationJWTConstants.DEVICE_IDENTIFIER)
private String deviceId;
- @SerializedName("loginHint")
+ @SerializedName(AppAuthValidationJWTConstants.LOGIN_HINT)
private String loginHint;
- @SerializedName("exp")
+ @SerializedName(AppAuthValidationJWTConstants.EXPIRY_TIME)
private Date expirationTime;
- @SerializedName("nbf")
+ @SerializedName(AppAuthValidationJWTConstants.NOT_VALID_BEFORE)
private Date notValidBefore;
- @SerializedName("jti")
+ @SerializedName(AppAuthValidationJWTConstants.JWT_ID)
private String jti;
- @SerializedName("ist")
+ @SerializedName(AppAuthValidationJWTConstants.ISSUED_TIME)
private Date issuedTime;
private SignedJWT signedJWT;
- private JWTClaimsSet jwtClaimsSet;
- private AuthenticatedUser authenticatedUser;
+ private String publicKey;
+ private String signingAlgorithm;
- public AppAuthValidationJWT(SignedJWT signedJWT) throws SecretValidationException {
+ public AppAuthValidationJWT(SignedJWT signedJWT)
+ throws JWTValidationException, ParseException {
- try {
- this.signedJWT = signedJWT;
- this.jwtClaimsSet = signedJWT.getJWTClaimsSet();
- this.expirationTime = jwtClaimsSet.getExpirationTime();
- this.notValidBefore = jwtClaimsSet.getNotBeforeTime();
- this.issuedTime = jwtClaimsSet.getIssueTime();
- this.jti = jwtClaimsSet.getJWTID();
- this.deviceId = getClaim(jwtClaimsSet,App2AppAuthenticatorConstants.DEVICE_IDENTIFIER);
- this.loginHint = getClaim(jwtClaimsSet,App2AppAuthenticatorConstants.LOGIN_HINT);
- } catch (IllegalArgumentException | ParseException e) {
- throw new SecretValidationException(e.getMessage());
- }
+ this.signedJWT = signedJWT;
+ JWTClaimsSet jwtClaimsSet = signedJWT.getJWTClaimsSet();
+ this.expirationTime = jwtClaimsSet.getExpirationTime();
+ this.notValidBefore = jwtClaimsSet.getNotBeforeTime();
+ this.issuedTime = jwtClaimsSet.getIssueTime();
+ this.jti = jwtClaimsSet.getJWTID();
+ this.deviceId = getClaim(jwtClaimsSet, AppAuthValidationJWTConstants.DEVICE_IDENTIFIER);
+ this.loginHint = getClaim(jwtClaimsSet, AppAuthValidationJWTConstants.LOGIN_HINT);
}
- @NotBlank(message = "Required Parameter did cannot be null or empty.", groups = RequiredParamChecks.class)
+ @NotBlank(message = "Required parameter did cannot be null or empty.", groups = RequiredParamChecks.class)
public String getDeviceId() {
return deviceId;
}
@@ -83,14 +78,14 @@ public String getDeviceId() {
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
- @NotBlank(message = "Required Parameter loginHint cannot be null or empty.", groups = RequiredParamChecks.class)
+ @NotBlank(message = "Required parameter loginHint cannot be null or empty.", groups = RequiredParamChecks.class)
public String getLoginHint() {
return loginHint;
}
public void setLoginHint(String loginHint) {
this.loginHint = loginHint;
}
- @NotNull(message = "Required Parameter exp cannot be null.", groups = RequiredParamChecks.class)
+ @NotNull(message = "Required parameter exp cannot be null.", groups = RequiredParamChecks.class)
public Date getExpirationTime() {
return expirationTime;
}
@@ -98,7 +93,7 @@ public Date getExpirationTime() {
public void setExpirationTime(Date expirationTime) {
this.expirationTime = expirationTime;
}
- @NotNull(message = "Required Parameter nbf cannot be null.", groups = RequiredParamChecks.class)
+ @NotNull(message = "Required parameter nbf cannot be null.", groups = RequiredParamChecks.class)
public Date getNotValidBefore() {
return notValidBefore;
}
@@ -106,15 +101,15 @@ public Date getNotValidBefore() {
public void setNotValidBefore(Date notValidBefore) {
this.notValidBefore = notValidBefore;
}
- @NotBlank(message = "Required Parameter jti cannot be null or empty.", groups = RequiredParamChecks.class)
+ @NotBlank(message = "Required parameter jti cannot be null or empty.", groups = RequiredParamChecks.class)
public String getJti() {
- return jwtClaimsSet.getJWTID();
+ return jti;
}
public void setJti(String jti) {
this.jti = jti;
}
- @NotNull(message = "Required Parameter iat cannot be null.", groups = RequiredParamChecks.class)
+ @NotNull(message = "Required parameter iat cannot be null.", groups = RequiredParamChecks.class)
public Date getIssuedTime() {
return issuedTime;
}
@@ -122,7 +117,7 @@ public Date getIssuedTime() {
public void setIssuedTime(Date issuedAt) {
this.issuedTime = issuedAt;
}
- @NotNull(message = "Required Parameter signedJWT cannot be null.", groups = RequiredParamChecks.class)
+ @NotNull(message = "Required parameter signedJWT cannot be null.", groups = RequiredParamChecks.class)
public SignedJWT getSignedJWT() {
return signedJWT;
}
@@ -131,21 +126,23 @@ public void setSignedJWT(SignedJWT signedJWT) {
this.signedJWT = signedJWT;
}
- public AuthenticatedUser getAuthenticatedUser() {
- return authenticatedUser;
+ @NotBlank(message = "Required parameter public key cannot be null or empty.", groups = RequiredParamChecks.class)
+ public String getPublicKey() {
+ return publicKey;
}
- public void setAuthenticatedUser(AuthenticatedUser authenticatedUser) {
- this.authenticatedUser = authenticatedUser;
+ public void setPublicKey(String publicKey) {
+ this.publicKey = publicKey;
}
- @NotNull(message = "Required Parameter jwtClaimsSet cannot be null.", groups = RequiredParamChecks.class)
- public JWTClaimsSet getJwtClaimsSet() {
- return jwtClaimsSet;
+ @NotBlank(message = "Required parameter signing algorithm cannot be null or empty.",
+ groups = RequiredParamChecks.class)
+ public String getSigningAlgorithm() {
+ return signingAlgorithm;
}
- public void setJwtClaimsSet(JWTClaimsSet jwtClaimsSet) {
- this.jwtClaimsSet = jwtClaimsSet;
+ public void setSigningAlgorithm(String signingAlgorithm) {
+ this.signingAlgorithm = signingAlgorithm;
}
/**
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/AppAuthValidationJWTConstants.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/AppAuthValidationJWTConstants.java
new file mode 100644
index 00000000..93502f70
--- /dev/null
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/AppAuthValidationJWTConstants.java
@@ -0,0 +1,12 @@
+package com.wso2.openbanking.accelerator.identity.app2app.model;
+
+public class AppAuthValidationJWTConstants {
+
+ public static final String EXPIRY_TIME = "exp";
+ public static final String NOT_VALID_BEFORE = "nbf";
+ public static final String LOGIN_HINT = "loginHint";
+ public static final String ISSUED_TIME = "ist";
+ public static final String DEVICE_IDENTIFIER = "did";
+ public static final String JWT_ID = "jti";
+
+}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/utils/App2AppAuthUtils.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/utils/App2AppAuthUtils.java
index 04cdf035..672a6bbc 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/utils/App2AppAuthUtils.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/utils/App2AppAuthUtils.java
@@ -18,9 +18,9 @@
package com.wso2.openbanking.accelerator.identity.app2app.utils;
import com.wso2.openbanking.accelerator.common.validator.OpenBankingValidator;
-import com.wso2.openbanking.accelerator.identity.app2app.exception.SecretValidationException;
+import com.wso2.openbanking.accelerator.identity.app2app.exception.JWTValidationException;
import com.wso2.openbanking.accelerator.identity.app2app.model.AppAuthValidationJWT;
-import com.wso2.openbanking.accelerator.identity.app2app.validations.validationgroups.ValidationOrder;
+import com.wso2.openbanking.accelerator.identity.app2app.validations.validationgroups.App2AppValidationOrder;
import com.wso2.openbanking.accelerator.identity.internal.IdentityExtensionsDataHolder;
import org.apache.commons.lang.StringUtils;
import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser;
@@ -155,15 +155,19 @@ public static String getPublicKey(String deviceID, String userID) throws PushDev
* Validator util to validate AppAuthValidationJWT model for given validationOrder.
*
* @param appAuthValidationJWT AppAuthValidationJWT object that needs to be validated
- * @throws SecretValidationException if validation f
+ * @throws JWTValidationException if validation f
*/
- public static void validateSecret(AppAuthValidationJWT appAuthValidationJWT) throws SecretValidationException {
-
- String error = OpenBankingValidator.getInstance().getFirstViolation(appAuthValidationJWT, ValidationOrder.class);
-
- //if there is a validation violation convert it to secretValidationException
+ public static void validateSecret(AppAuthValidationJWT appAuthValidationJWT) throws JWTValidationException {
+ /*
+ App2AppValidationOrder validation order
+ 1.Required Params validation
+ 2.Validity Validations - Signature, JTI, Timeliness will be validated.
+ */
+ String error = OpenBankingValidator.getInstance().getFirstViolation(appAuthValidationJWT, App2AppValidationOrder.class);
+
+ //if there is a validation violation convert it to JWTValidationException
if (error != null) {
- throw new SecretValidationException(error);
+ throw new JWTValidationException(error);
}
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JwtTokenTimelinessValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JwtTokenTimelinessValidator.java
index 4d454243..6e3af032 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JwtTokenTimelinessValidator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JwtTokenTimelinessValidator.java
@@ -18,6 +18,7 @@
package com.wso2.openbanking.accelerator.identity.app2app.validations;
import com.nimbusds.jwt.JWTClaimsSet;
+import com.nimbusds.jwt.SignedJWT;
import com.wso2.openbanking.accelerator.common.util.JWTUtils;
import com.wso2.openbanking.accelerator.identity.app2app.model.AppAuthValidationJWT;
import com.wso2.openbanking.accelerator.identity.app2app.validations.annotations.ValidateTimeliness;
@@ -26,6 +27,7 @@
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
+import java.text.ParseException;
/**
* Validator class for validating the timeliness of a JWT.
@@ -37,17 +39,25 @@ public class JwtTokenTimelinessValidator implements ConstraintValidator {
- private static final Log log = LogFactory.getLog(SignatureValidator.class);
- private String algorithm;
- @Override
- public void initialize(ValidateSignature validateSignature) {
-
- this.algorithm = validateSignature.algorithm();
-
- }
+public class PublicKeySignatureValidator implements ConstraintValidator {
+ private static final Log log = LogFactory.getLog(PublicKeySignatureValidator.class);
@Override
public boolean isValid(AppAuthValidationJWT appAuthValidationJWT, ConstraintValidatorContext constraintValidatorContext) {
@@ -56,27 +42,15 @@ public boolean isValid(AppAuthValidationJWT appAuthValidationJWT, ConstraintVali
try {
SignedJWT signedJWT = appAuthValidationJWT.getSignedJWT();
- String deviceID = appAuthValidationJWT.getDeviceId();
- AuthenticatedUser authenticatedUser = appAuthValidationJWT.getAuthenticatedUser();
- UserRealm userRealm = App2AppAuthUtils.getUserRealm(authenticatedUser);
- String userID = App2AppAuthUtils.getUserIdFromUsername(authenticatedUser.getUserName(), userRealm);
- String publicKey = App2AppAuthUtils.getPublicKey(deviceID, userID);
-
+ String publicKey = appAuthValidationJWT.getPublicKey();
+ String algorithm = appAuthValidationJWT.getSigningAlgorithm();
if (!JWTUtils.validateJWTSignature(signedJWT, publicKey, algorithm)) {
log.error("Signature can't be verified with registered public key.");
return false;
}
- } catch (UserStoreException e) {
- log.error("Error while creating authenticated user.", e);
- return false;
- } catch (PushDeviceHandlerServerException e) {
- log.error("Error occurred push device handler service.", e);
- return false;
- } catch (PushDeviceHandlerClientException e) {
- log.error("Push Device handler client.", e);
- return false;
+
} catch (NoSuchAlgorithmException e) {
- log.error("No such algorithm found -" + algorithm + ".", e);
+ log.error("No such algorithm found.", e);
return false;
} catch (InvalidKeySpecException e) {
log.error("Invalid key spec.", e);
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateSignature.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateSignature.java
index eee37bb4..e6c963a8 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateSignature.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateSignature.java
@@ -17,7 +17,7 @@
*/
package com.wso2.openbanking.accelerator.identity.app2app.validations.annotations;
-import com.wso2.openbanking.accelerator.identity.app2app.validations.SignatureValidator;
+import com.wso2.openbanking.accelerator.identity.app2app.validations.PublicKeySignatureValidator;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
@@ -35,12 +35,12 @@
@Target(TYPE)
@Retention(RUNTIME)
@Documented
-@Constraint(validatedBy = {SignatureValidator.class})
+@Constraint(validatedBy = {PublicKeySignatureValidator.class})
public @interface ValidateSignature {
String message() default "Signature validation Failed.";
Class>[] groups() default {};
Class extends Payload>[] payload() default {};
- String algorithm();
+
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/validationgroups/ValidationOrder.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/validationgroups/App2AppValidationOrder.java
similarity index 95%
rename from open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/validationgroups/ValidationOrder.java
rename to open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/validationgroups/App2AppValidationOrder.java
index 89bf2c6a..09e3e609 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/validationgroups/ValidationOrder.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/validationgroups/App2AppValidationOrder.java
@@ -23,5 +23,5 @@
* Class to define the order of execution for the hibernate validation groups.
*/
@GroupSequence({RequiredParamChecks.class, ValidityChecks.class})
-public interface ValidationOrder {
+public interface App2AppValidationOrder {
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorTest.java
index ad29e619..843bdc51 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorTest.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorTest.java
@@ -1,6 +1,5 @@
package com.wso2.openbanking.accelerator.identity.app2app;
-import com.wso2.openbanking.accelerator.identity.app2app.utils.App2AppAuthUtils;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext;
@@ -44,7 +43,7 @@ public void testGetFriendlyName() {
public void canHandleTestCase(String secret, String expected) {
mockRequest = mock(HttpServletRequest.class);
- when(mockRequest.getParameter(App2AppAuthenticatorConstants.SECRET)).thenReturn(secret);
+ when(mockRequest.getParameter(App2AppAuthenticatorConstants.AppAuthValidationJWTIdentifier)).thenReturn(secret);
assertEquals(Boolean.valueOf(expected).booleanValue(), app2AppAuthenticator.canHandle(mockRequest),
"Invalid can handle response for the request.");
}
@@ -82,7 +81,7 @@ public void testProcessAuthenticationResponse_InvalidJWT(String jwtString) throw
AuthenticationContext authContextMock = mock(AuthenticationContext.class);
// Set up mock behavior for HttpServletRequest
- when(requestMock.getParameter(App2AppAuthenticatorConstants.SECRET)).thenReturn(jwtString);
+ when(requestMock.getParameter(App2AppAuthenticatorConstants.AppAuthValidationJWTIdentifier)).thenReturn(jwtString);
// Call the method under test, expecting an exception
try {
App2AppAuthenticator authenticator = new App2AppAuthenticator();
From 4d2591bf70010c42e461d65ba8bbfa46340a1bb1 Mon Sep 17 00:00:00 2001
From: ImalshaD
Date: Sun, 12 May 2024 23:30:27 +0530
Subject: [PATCH 147/281] Optimised Imports.
---
.../app2app/validations/JwtTokenTimelinessValidator.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JwtTokenTimelinessValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JwtTokenTimelinessValidator.java
index 6e3af032..194b85dd 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JwtTokenTimelinessValidator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JwtTokenTimelinessValidator.java
@@ -17,7 +17,6 @@
*/
package com.wso2.openbanking.accelerator.identity.app2app.validations;
-import com.nimbusds.jwt.JWTClaimsSet;
import com.nimbusds.jwt.SignedJWT;
import com.wso2.openbanking.accelerator.common.util.JWTUtils;
import com.wso2.openbanking.accelerator.identity.app2app.model.AppAuthValidationJWT;
From b02ea52720c42d4419e4f77e1ddcd7c526036f42 Mon Sep 17 00:00:00 2001
From: "Venukshi N. Mendis" <119746771+VenukshiMendis@users.noreply.github.com>
Date: Wed, 15 May 2024 00:15:40 +0530
Subject: [PATCH 148/281] Modify DCR Flow to make SSA an optional parameter
---
.../config/OpenBankingConfigParser.java | 5 +
.../common/constant/OpenBankingConstants.java | 1 +
.../common/util/OpenBankingUtils.java | 20 ++--
.../gateway/executor/dcr/DCRExecutor.java | 101 +++++++++++-------
.../executor/model/OBAPIRequestContext.java | 3 +-
.../dcr/model/RegistrationRequest.java | 12 +++
.../dcr/model/RegistrationResponse.java | 11 ++
.../dcr/validation/IssuerValidator.java | 6 +-
.../validation/RequiredParamsValidator.java | 2 +-
.../dcr/validation/SignatureValidator.java | 48 +++++----
.../pom.xml | 4 +-
.../impl/api/ClientRegistrationApiImpl.java | 39 +++----
.../service/RegistrationServiceHandler.java | 37 ++++---
.../endpoint/impl/util/RegistrationUtils.java | 61 +++++++----
14 files changed, 216 insertions(+), 134 deletions(-)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/config/OpenBankingConfigParser.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/config/OpenBankingConfigParser.java
index d9c77296..eaee62a1 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/config/OpenBankingConfigParser.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/config/OpenBankingConfigParser.java
@@ -38,6 +38,7 @@
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
@@ -49,6 +50,7 @@
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
+
import static java.util.Map.Entry.comparingByKey;
/**
@@ -582,6 +584,9 @@ private void buildAllowedSubscriptions() {
.collect(Collectors.toList());
allowedAPIs.put(scopeName, rolesList);
}
+ else if(StringUtils.isEmpty(rolesStr)) {
+ allowedAPIs.put(scopeName, Collections.emptyList());
+ }
}
}
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/constant/OpenBankingConstants.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/constant/OpenBankingConstants.java
index 6f4a6e3f..0df62b2d 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/constant/OpenBankingConstants.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/constant/OpenBankingConstants.java
@@ -78,6 +78,7 @@ public class OpenBankingConstants {
public static final String REGULATORY_API = "API";
public static final String SOFTWARE_ROLES = "software_roles";
public static final String SOFTWARE_STATEMENT = "software_statement";
+ public static final String SOFTWARE_ID = "software_id";
public static final String SOFTWARE_ENVIRONMENT = "software_environment";
public static final String TOKEN_ENDPOINT = "DCR.TokenEndpoint";
public static final String STORE_HOSTNAME = "PublisherURL";
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/OpenBankingUtils.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/OpenBankingUtils.java
index 94504bec..2f082833 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/OpenBankingUtils.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/OpenBankingUtils.java
@@ -72,15 +72,17 @@ public static String getSoftwareEnvironmentFromSSA(String softwareStatement) thr
String prodEnvIdentificationValue = OpenBankingConfigParser.getInstance()
.getSoftwareEnvIdentificationSSAPropertyValueForProduction();
String softwareEnvironment = IdentityConstants.PRODUCTION;
- // decode software statement and get softwareEnvironment
- JSONObject softwareStatementBody = JWTUtils.decodeRequestJWT(softwareStatement, "body");
- Object softwareEnvironmentValue = softwareStatementBody.get(sandboxEnvIdentificationPropertyName);
- if (softwareEnvironmentValue != null &&
- softwareEnvironmentValue.toString().equalsIgnoreCase(sandboxEnvIdentificationValue)) {
- softwareEnvironment = IdentityConstants.SANDBOX;
- } else if (softwareEnvironmentValue != null &&
- softwareEnvironmentValue.toString().equalsIgnoreCase(prodEnvIdentificationValue)) {
- softwareEnvironment = IdentityConstants.PRODUCTION;
+ if (softwareStatement != null) {
+ // decode software statement and get softwareEnvironment
+ JSONObject softwareStatementBody = JWTUtils.decodeRequestJWT(softwareStatement, "body");
+ Object softwareEnvironmentValue = softwareStatementBody.get(sandboxEnvIdentificationPropertyName);
+ if (softwareEnvironmentValue != null &&
+ softwareEnvironmentValue.toString().equalsIgnoreCase(sandboxEnvIdentificationValue)) {
+ softwareEnvironment = IdentityConstants.SANDBOX;
+ } else if (softwareEnvironmentValue != null &&
+ softwareEnvironmentValue.toString().equalsIgnoreCase(prodEnvIdentificationValue)) {
+ softwareEnvironment = IdentityConstants.PRODUCTION;
+ }
}
return softwareEnvironment;
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/dcr/DCRExecutor.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/dcr/DCRExecutor.java
index f4c2e114..31e3378a 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/dcr/DCRExecutor.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/dcr/DCRExecutor.java
@@ -15,6 +15,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+
package com.wso2.openbanking.accelerator.gateway.executor.dcr;
import com.google.gson.JsonArray;
@@ -27,6 +28,7 @@
import com.wso2.openbanking.accelerator.common.constant.OpenBankingConstants;
import com.wso2.openbanking.accelerator.common.error.OpenBankingErrorCodes;
import com.wso2.openbanking.accelerator.common.exception.OpenBankingException;
+import com.wso2.openbanking.accelerator.common.identity.IdentityConstants;
import com.wso2.openbanking.accelerator.common.util.Generated;
import com.wso2.openbanking.accelerator.common.util.HTTPClientUtils;
import com.wso2.openbanking.accelerator.common.util.JWTUtils;
@@ -70,6 +72,7 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.text.ParseException;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -157,8 +160,10 @@ public void postProcessResponse(OBAPIResponseContext obapiResponseContext) {
JsonParser jsonParser = new JsonParser();
JsonObject createdDCRAppDetails = ((JsonObject) jsonParser
.parse(obapiResponseContext.getResponsePayload()));
- String softwareStatement = createdDCRAppDetails.get(OpenBankingConstants.SOFTWARE_STATEMENT)
- .getAsString();
+
+ JsonElement softwareStatementJson = createdDCRAppDetails.get(OpenBankingConstants.SOFTWARE_STATEMENT);
+ String softwareStatement = (softwareStatementJson != null) ? softwareStatementJson.toString() : null;
+
//call IS DCR endpoint to create application for obtaining a token to invoke devportal REST APIs
JsonElement registrationResponse = createServiceProvider(basicAuthHeader,
createdDCRAppDetails.get("software_id").getAsString());
@@ -275,9 +280,14 @@ public void postProcessResponse(OBAPIResponseContext obapiResponseContext) {
}
List apiIDList = new ArrayList<>();
- if (regulatoryAPIs != null) {
- apiIDList = filterRegulatorAPIs(regulatoryAPIs, publishedAPIsResponse.getAsJsonObject()
- .get("list").getAsJsonArray(), getRolesFromSSA(softwareStatement));
+ if (regulatoryAPIs != null ) {
+ if (softwareStatement != null) {
+ apiIDList = filterRegulatorAPIs(regulatoryAPIs, publishedAPIsResponse.getAsJsonObject()
+ .get("list").getAsJsonArray(), getRolesFromSSA(softwareStatement));
+ } else {
+ apiIDList = filterRegulatorAPIs(regulatoryAPIs, publishedAPIsResponse.getAsJsonObject()
+ .get("list").getAsJsonArray());
+ }
} else {
log.warn("No regulatory APIs configured. Application will be subscribed to all published APIs");
//subscribe to all APIs if there are no configured regulatory APIs
@@ -387,29 +397,32 @@ public void postProcessResponse(OBAPIResponseContext obapiResponseContext) {
handleInternalServerError(obapiResponseContext, OpenBankingErrorCodes.REGISTRATION_UPDATE_ERROR);
return;
}
- List allowedRoles = getRolesFromSSA(createdDCRAppDetails
- .get(OpenBankingConstants.SOFTWARE_STATEMENT).getAsString());
List subscribedAPIIdList = new ArrayList<>();
for (JsonElement subscribedAPI : subscribedAPIsResponse.getAsJsonObject().get("list")
.getAsJsonArray()) {
String apiId = subscribedAPI.getAsJsonObject().get("apiId").getAsString();
subscribedAPIIdList.add(apiId);
}
- //check whether the ssa still contains the roles related to the subscribed APIs
- List unsubscribedAPIs = getUnAuthorizedAPIs(subscribedAPIsResponse.getAsJsonObject()
- .get("list").getAsJsonArray(), regulatoryAPIs, allowedRoles);
- if (!unsubscribedAPIs.isEmpty()) {
- //unsubscribe from the apis
- for (String subscriptionId : unsubscribedAPIs) {
- if (!callDelete(urlMap.get(GatewayConstants.API_GET_SUBSCRIBED).toString()
- .concat("/").concat(subscriptionId), GatewayConstants.BEARER_TAG.concat(token))) {
- log.error("Error while unsubscribing from APIs");
- //delete SP created to call dev portal REST APIs
- callDelete(urlMap.get(GatewayConstants.IAM_DCR_URL).toString().concat("/")
- .concat(clientId), basicAuthHeader);
- handleInternalServerError(obapiResponseContext,
- OpenBankingErrorCodes.REGISTRATION_INTERNAL_ERROR);
- return;
+
+ JsonElement softwareStatementJson = createdDCRAppDetails.get(OpenBankingConstants.SOFTWARE_STATEMENT);
+ if (softwareStatementJson != null) {
+ String softwareStatement = softwareStatementJson.getAsString();
+ List allowedRoles = getRolesFromSSA(softwareStatement);
+ List unsubscribedAPIs = getUnAuthorizedAPIs(subscribedAPIsResponse.getAsJsonObject()
+ .get("list").getAsJsonArray(), regulatoryAPIs, allowedRoles);
+ if (!unsubscribedAPIs.isEmpty()) {
+ //unsubscribe from the apis
+ for (String subscriptionId : unsubscribedAPIs) {
+ if (!callDelete(urlMap.get(GatewayConstants.API_GET_SUBSCRIBED).toString()
+ .concat("/").concat(subscriptionId), GatewayConstants.BEARER_TAG.concat(token))) {
+ log.error("Error while unsubscribing from APIs");
+ //delete SP created to call dev portal REST APIs
+ callDelete(urlMap.get(GatewayConstants.IAM_DCR_URL).toString().concat("/")
+ .concat(clientId), basicAuthHeader);
+ handleInternalServerError(obapiResponseContext,
+ OpenBankingErrorCodes.REGISTRATION_INTERNAL_ERROR);
+ return;
+ }
}
}
}
@@ -425,8 +438,12 @@ public void postProcessResponse(OBAPIResponseContext obapiResponseContext) {
handleInternalServerError(obapiResponseContext, OpenBankingErrorCodes.REGISTRATION_UPDATE_ERROR);
return;
}
- List apiIDList = filterRegulatorAPIs(regulatoryAPIs, publishedAPIsResponse.getAsJsonObject()
- .get("list").getAsJsonArray(), allowedRoles);
+ List apiIDList = (softwareStatementJson == null) ?
+ filterRegulatorAPIs(regulatoryAPIs, publishedAPIsResponse.getAsJsonObject()
+ .get("list").getAsJsonArray()) :
+ filterRegulatorAPIs(regulatoryAPIs, publishedAPIsResponse.getAsJsonObject()
+ .get("list").getAsJsonArray(), getRolesFromSSA(softwareStatementJson.toString()));
+
List newApisListToSubscribe = getNewAPIsToSubscribe(apiIDList, subscribedAPIIdList);
if (!newApisListToSubscribe.isEmpty()) {
JsonArray subscribeAPIsPayload = getAPISubscriptionPayload(applicationId, newApisListToSubscribe);
@@ -736,6 +753,17 @@ protected List filterRegulatorAPIs(Map> regulatoryA
return filteredAPIs;
}
+ protected List filterRegulatorAPIs(Map> regulatoryAPINames, JsonArray publishedAPIs) {
+
+ List filteredAPIs = new ArrayList<>();
+ for (JsonElement apiInfo : publishedAPIs) {
+ if(regulatoryAPINames.containsKey(apiInfo.getAsJsonObject().get("name").getAsString())) {
+ filteredAPIs.add(apiInfo.getAsJsonObject().get("id").getAsString());
+ }
+ }
+ return filteredAPIs;
+ }
+
@Generated(message = "Excluding from test coverage since it is an HTTP call")
protected JsonElement callGet(String endpoint, String authHeader, String queryParamKey, String paramValue)
throws IOException, OpenBankingException, URISyntaxException {
@@ -876,26 +904,25 @@ protected String getApplicationName(String responsePayload, Map
.get(OpenBankingConstants.DCR_USE_SOFTWAREID_AS_APPNAME).toString());
String applicationNameKey = configurations
.get(OpenBankingConstants.DCR_APPLICATION_NAME_KEY).toString();
- String applicationName = "";
JsonParser jsonParser = new JsonParser();
JsonObject createdDCRAppDetails = ((JsonObject) jsonParser.parse(responsePayload));
- String softwareStatement = createdDCRAppDetails.get(OpenBankingConstants.SOFTWARE_STATEMENT)
- .getAsString();
+ JsonElement softwareStatementJson = createdDCRAppDetails.get(OpenBankingConstants.SOFTWARE_STATEMENT);
+
+ if(softwareStatementJson == null) {
+ return createdDCRAppDetails.get(OpenBankingConstants.SOFTWARE_ID).getAsString();
+ }
+ String softwareStatement = softwareStatementJson.getAsString();
JSONObject softwareStatementBody = JWTUtils.decodeRequestJWT(softwareStatement, "body");
//get application Name
if (isSoftwareIdAppName) {
- if (softwareStatementBody.containsKey("software_id")) {
- applicationName = softwareStatementBody.get("software_id").toString();
- }
- } else {
- if (softwareStatementBody.containsKey(applicationNameKey)) {
- applicationName = softwareStatementBody.get(applicationNameKey).toString();
- } else {
- applicationName = createdDCRAppDetails.get(applicationNameKey).toString();
+ if (softwareStatementBody.containsKey(OpenBankingConstants.SOFTWARE_ID)) {
+ return softwareStatementBody.get(OpenBankingConstants.SOFTWARE_ID).toString();
}
+ return null;
}
-
- return applicationName;
+ return softwareStatementBody.containsKey(applicationNameKey) ?
+ softwareStatementBody.get(applicationNameKey).toString() :
+ createdDCRAppDetails.get(applicationNameKey).getAsString();
}
protected List getUnAuthorizedAPIs(JsonArray subscribedAPIs, Map> configuredAPIs,
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/model/OBAPIRequestContext.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/model/OBAPIRequestContext.java
index d7ec47f8..9421d034 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/model/OBAPIRequestContext.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/model/OBAPIRequestContext.java
@@ -62,10 +62,9 @@ public OBAPIRequestContext(RequestContextDTO requestContextDTO,
Map contextProps, Map analyticsData) {
this.requestContextDTO = requestContextDTO;
- this.contextProps = contextProps;
this.addedHeaders = new HashMap<>();
this.errors = new ArrayList<>();
- this.contextProps = new HashMap<>();
+ this.contextProps = contextProps;
this.analyticsData = analyticsData;
Map headers = requestContextDTO.getMsgInfo().getHeaders();
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/model/RegistrationRequest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/model/RegistrationRequest.java
index 658fd094..6e819de1 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/model/RegistrationRequest.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/model/RegistrationRequest.java
@@ -54,6 +54,9 @@ public class RegistrationRequest {
@SerializedName("token_endpoint_auth_method")
private String tokenEndPointAuthMethod;
+ @SerializedName("jwks_uri")
+ private String jwksURI;
+
@SerializedName("grant_types")
private List grantTypes;
@@ -108,6 +111,8 @@ public class RegistrationRequest {
@SerializedName("backchannel_user_code_parameter_supported")
private boolean backchannelUserCodeParameterSupported;
+
+
private SoftwareStatementBody softwareStatementBody;
private Map requestParameters;
@@ -353,4 +358,11 @@ public void setJti(String jti) {
this.jti = jti;
}
+ public String getJwksURI() {
+ return jwksURI;
+ }
+
+ public void setJwksURI(String jwksURI) {
+ this.jwksURI = jwksURI;
+ }
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/model/RegistrationResponse.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/model/RegistrationResponse.java
index 080b9765..8078f34a 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/model/RegistrationResponse.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/model/RegistrationResponse.java
@@ -69,6 +69,9 @@ public void setToken(String token) {
@SerializedName("software_id")
protected String softwareId = null;
+ @SerializedName("jwks_uri")
+ private String jwksURI;
+
@SerializedName("token_endpoint_auth_method")
protected String tokenEndpointAuthMethod = null;
@@ -206,4 +209,12 @@ public String getRegistrationClientURI() {
public void setRegistrationClientURI(String registrationClientURI) {
this.registrationClientURI = registrationClientURI;
}
+
+ public String getJwksURI() {
+ return jwksURI;
+ }
+
+ public void setJwksURI(String jwksURI) {
+ this.jwksURI = jwksURI;
+ }
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/validation/IssuerValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/validation/IssuerValidator.java
index 8d7e45bd..0994123f 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/validation/IssuerValidator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/validation/IssuerValidator.java
@@ -20,6 +20,7 @@
import com.wso2.openbanking.accelerator.common.util.JWTUtils;
import com.wso2.openbanking.accelerator.identity.dcr.validation.annotation.ValidateIssuer;
import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -52,13 +53,14 @@ public boolean isValid(Object registrationRequest,
try {
String issuer = BeanUtils.getProperty(registrationRequest, issuerPath);
- if (issuer != null) {
- String softwareStatement = BeanUtils.getProperty(registrationRequest, ssaPath);
+ String softwareStatement = BeanUtils.getProperty(registrationRequest, ssaPath);
+ if (issuer != null && softwareStatement != null) {
String softwareId = JWTUtils.decodeRequestJWT(softwareStatement, "body")
.getAsString(DCRCommonConstants.SOFTWARE_ID);
if (softwareId != null && softwareId.equals(issuer)) {
return true;
}
+
} else {
return true;
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/validation/RequiredParamsValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/validation/RequiredParamsValidator.java
index 12a96b96..2b37bc65 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/validation/RequiredParamsValidator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/validation/RequiredParamsValidator.java
@@ -69,7 +69,7 @@ public boolean isValid(Object registrationRequestObject, ConstraintValidatorCont
.addConstraintViolation();
return false;
}
- //validate string type required parameters
+ //validate list type required parameters
if (requestParameterMap.get(camelCaseConfigParam) instanceof List) {
List param = (List) requestParameterMap.get(camelCaseConfigParam);
if (param.isEmpty()) {
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/validation/SignatureValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/validation/SignatureValidator.java
index 29091566..c32b5f97 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/validation/SignatureValidator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/validation/SignatureValidator.java
@@ -58,32 +58,34 @@ public boolean isValid(Object registrationRequest,
ConstraintValidatorContext constraintValidatorContext) {
try {
+ String softwareStatement = BeanUtils.getProperty(registrationRequest, softwareStatementPath);
+ if (softwareStatement != null ) {
+ SignedJWT signedJWT = SignedJWT.parse(softwareStatement);
+ String jwtString = signedJWT.getParsedString();
+ String alg = signedJWT.getHeader().getAlgorithm().getName();
+ String softwareEnvironmentFromSSA = OpenBankingUtils.getSoftwareEnvironmentFromSSA(jwtString);
+ String jwksURL;
- boolean isValidSignature = false;
- SignedJWT signedJWT = SignedJWT.parse(BeanUtils.getProperty(registrationRequest, softwareStatementPath));
- String jwtString = signedJWT.getParsedString();
- String alg = signedJWT.getHeader().getAlgorithm().getName();
- String softwareEnvironmentFromSSA = OpenBankingUtils.getSoftwareEnvironmentFromSSA(jwtString);
- String jwksURL;
-
- if (IdentityConstants.PRODUCTION.equals(softwareEnvironmentFromSSA)) {
- // validate the signature against production jwks
- jwksURL = IdentityExtensionsDataHolder.getInstance().getConfigurationMap()
- .get(DCRCommonConstants.DCR_JWKS_ENDPOINT_PRODUCTION).toString();
- if (log.isDebugEnabled()) {
- log.debug(String.format("Validating the signature from Production JwksUrl %s",
- jwksURL.replaceAll("[\r\n]", "")));
- }
- } else {
- // else validate the signature against sandbox jwks
- jwksURL = IdentityExtensionsDataHolder.getInstance().getConfigurationMap()
- .get(DCRCommonConstants.DCR_JWKS_ENDPOINT_SANDBOX).toString();
- if (log.isDebugEnabled()) {
- log.debug(String.format("Validating the signature from Sandbox JwksUrl %s",
- jwksURL.replaceAll("[\r\n]", "")));
+ if (IdentityConstants.PRODUCTION.equals(softwareEnvironmentFromSSA)) {
+ // validate the signature against production jwks
+ jwksURL = IdentityExtensionsDataHolder.getInstance().getConfigurationMap()
+ .get(DCRCommonConstants.DCR_JWKS_ENDPOINT_PRODUCTION).toString();
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Validating the signature from Production JwksUrl %s",
+ jwksURL.replaceAll("[\r\n]", "")));
+ }
+ } else {
+ // else validate the signature against sandbox jwks
+ jwksURL = IdentityExtensionsDataHolder.getInstance().getConfigurationMap()
+ .get(DCRCommonConstants.DCR_JWKS_ENDPOINT_SANDBOX).toString();
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Validating the signature from Sandbox JwksUrl %s",
+ jwksURL.replaceAll("[\r\n]", "")));
+ }
}
+ return isValidateJWTSignature(jwksURL, jwtString, alg);
}
- return isValidateJWTSignature(jwksURL, jwtString, alg);
+ return true;
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
log.error("Error while resolving validation fields", e);
} catch (ParseException e) {
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
index 1e89ac64..58394020 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
@@ -183,8 +183,8 @@
truetrue${project.basedir}/src/main/resources/dynamic.client.registration.yaml
- jaxrs-cxf
+ jaxrs-cxfsrc/gen/javatrue
@@ -200,4 +200,4 @@
-
+
\ No newline at end of file
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/endpoint/impl/api/ClientRegistrationApiImpl.java b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/endpoint/impl/api/ClientRegistrationApiImpl.java
index ad6eeb14..8aa6e1c6 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/endpoint/impl/api/ClientRegistrationApiImpl.java
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/endpoint/impl/api/ClientRegistrationApiImpl.java
@@ -173,19 +173,14 @@ public Response registerClientIdPut(@Context HttpServletRequest request, @Contex
Map requestAttributes = (Map)
gson.fromJson(registrationRequestDetails, Map.class);
- //decode SSA
- if (registrationRequest.getSoftwareStatement() == null) {
- return Response.status(Response.Status.BAD_REQUEST).entity(RegistrationUtils
- .getErrorDTO(DCRCommonConstants.INVALID_META_DATA,
- "Required parameter software statement cannot be null"))
- .build();
- }
- String ssaBody = JWTUtils.decodeRequestJWT(registrationRequest.getSoftwareStatement(), "body")
- .toString();
- Map ssaAttributesMap = gson.fromJson(ssaBody, Map.class);
- //RegistrationRequest registrationRequest = RegistrationUtils.getRegistrationRequest(requestAttributeMap);
registrationRequest.setRequestParameters(requestAttributes);
- registrationRequest.setSsaParameters(ssaAttributesMap);
+
+ if (registrationRequest.getSoftwareStatement() != null) {
+ String ssaBody = JWTUtils.decodeRequestJWT(registrationRequest.getSoftwareStatement(), "body")
+ .toString();
+ Map ssaAttributesMap = gson.fromJson(ssaBody, Map.class);
+ registrationRequest.setSsaParameters(ssaAttributesMap);
+ }
String clientId = uriInfo.getPathParameters().getFirst("s");
RegistrationUtils.validateRegistrationCreation(registrationRequest);
@@ -265,19 +260,17 @@ public Response registerPost(@Context HttpServletRequest request, @Context HttpS
log.error("Certificate not valid", e);
}
- //decode SSA
- if (StringUtils.isBlank(registrationRequest.getSoftwareStatement())) {
- return Response.status(Response.Status.BAD_REQUEST).entity(RegistrationUtils
- .getErrorDTO(DCRCommonConstants.INVALID_META_DATA,
- "Required parameter software statement cannot be null"))
- .build();
+ registrationRequest.setRequestParameters(requestAttributes);
+
+ //decode SSA if provided in the registration request
+ if (registrationRequest.getSoftwareStatement() != null) {
+ String ssaBody = JWTUtils.decodeRequestJWT(registrationRequest.getSoftwareStatement(), "body")
+ .toString();
+ Map ssaAttributesMap = gson.fromJson(ssaBody, Map.class);
+ registrationRequest.setSsaParameters(ssaAttributesMap);
+
}
- String ssaBody = JWTUtils.decodeRequestJWT(registrationRequest.getSoftwareStatement(), "body")
- .toString();
- Map ssaAttributesMap = gson.fromJson(ssaBody, Map.class);
- registrationRequest.setRequestParameters(requestAttributes);
- registrationRequest.setSsaParameters(ssaAttributesMap);
RegistrationUtils.validateRegistrationCreation(registrationRequest);
//do specific validations
registrationValidator.validatePost(registrationRequest);
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/endpoint/impl/service/RegistrationServiceHandler.java b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/endpoint/impl/service/RegistrationServiceHandler.java
index 8aa4a4ed..883f0d70 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/endpoint/impl/service/RegistrationServiceHandler.java
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/endpoint/impl/service/RegistrationServiceHandler.java
@@ -84,10 +84,15 @@ public Response createRegistration(RegistrationRequest registrationRequest,
ServiceProvider serviceProvider = applicationManagementService
.getServiceProvider(application.getClientName(), tenantDomain);
- if (StringUtils.isNotEmpty(jwksEndpointName)) {
- serviceProvider.setJwksUri(registrationRequest.getSsaParameters().get(jwksEndpointName).toString());
- } else {
- serviceProvider.setJwksUri(registrationRequest.getSoftwareStatementBody().getJwksURI());
+ if (registrationRequest.getSoftwareStatement() == null) {
+ serviceProvider.setJwksUri(registrationRequest.getJwksURI());
+ }
+ else {
+ if (StringUtils.isNotEmpty(jwksEndpointName)) {
+ serviceProvider.setJwksUri(registrationRequest.getSsaParameters().get(jwksEndpointName).toString());
+ } else {
+ serviceProvider.setJwksUri(registrationRequest.getSoftwareStatementBody().getJwksURI());
+ }
}
Long clientIdIssuedTime = Instant.now().getEpochSecond();
@@ -108,7 +113,9 @@ public Response createRegistration(RegistrationRequest registrationRequest,
Map registrationData = registrationRequest.getRequestParameters();
registrationData.put(RegistrationConstants.CLIENT_ID, application.getClientId());
registrationData.put(RegistrationConstants.CLIENT_ID_ISSUED_AT, clientIdIssuedTime.toString());
- registrationData.putAll(registrationRequest.getSsaParameters());
+ if(registrationRequest.getSsaParameters() != null) {
+ registrationData.putAll(registrationRequest.getSsaParameters());
+ }
registrationData.putAll(additionalAttributes);
String registrationResponse = registrationValidator.getRegistrationResponse(registrationData);
return Response.status(Response.Status.CREATED).entity(registrationResponse).build();
@@ -166,7 +173,9 @@ public Response updateRegistration(RegistrationRequest request, Map updateRequestData = RegistrationUtils.getAlteredApplicationAttributes(request);
Map updateRegistrationData = request.getRequestParameters();
- updateRegistrationData.putAll(request.getSsaParameters());
+ if(request.getSsaParameters() != null) {
+ updateRegistrationData.putAll(request.getSsaParameters());
+ }
updateRequestData.put(RegistrationConstants.CLIENT_ID_ISSUED_AT, clientIdIssuedAt);
// Adding SP property to identify update request. Will be removed when updating authenticators.
updateRequestData.put("AppCreateRequest", "false");
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/endpoint/impl/util/RegistrationUtils.java b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/endpoint/impl/util/RegistrationUtils.java
index 158f4008..d1c890fd 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/endpoint/impl/util/RegistrationUtils.java
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/endpoint/impl/util/RegistrationUtils.java
@@ -18,9 +18,10 @@
package com.wso2.openbanking.accelerator.identity.dcr.endpoint.impl.util;
import com.google.gson.Gson;
-import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
+
+
import com.wso2.openbanking.accelerator.common.util.JWTUtils;
import com.wso2.openbanking.accelerator.identity.dcr.endpoint.impl.dto.RegistrationErrorDTO;
import com.wso2.openbanking.accelerator.identity.dcr.exception.DCRValidationException;
@@ -108,15 +109,26 @@ public static ApplicationRegistrationRequest getApplicationRegistrationRequest(
RegistrationRequest registrationRequest, boolean useSoftwareIdAsAppName) {
String applicationName = "";
- if (useSoftwareIdAsAppName) {
- applicationName = registrationRequest.getSoftwareStatementBody().getSoftwareId();
+ if (StringUtils.isBlank(registrationRequest.getSoftwareStatement())) {
+ applicationName = registrationRequest.getSoftwareId();
} else {
- applicationName = RegistrationUtils.getSafeApplicationName(
- registrationRequest.getSoftwareStatementBody().getClientName());
+ if (useSoftwareIdAsAppName) {
+ applicationName = registrationRequest.getSoftwareStatementBody().getSoftwareId();
+ } else {
+ applicationName = RegistrationUtils.getSafeApplicationName(
+ registrationRequest.getSoftwareStatementBody().getClientName());
+ }
}
+
ApplicationRegistrationRequest appRegistrationRequest = new ApplicationRegistrationRequest();
appRegistrationRequest.setClientName(applicationName);
- appRegistrationRequest.setRedirectUris(registrationRequest.getSoftwareStatementBody().getCallbackUris());
+
+ // Set the redirect URIs based on the presence of software statement
+ appRegistrationRequest.setRedirectUris(
+ StringUtils.isBlank(registrationRequest.getSoftwareStatement()) ?
+ registrationRequest.getCallbackUris() :
+ registrationRequest.getSoftwareStatementBody().getCallbackUris());
+
appRegistrationRequest.setGrantTypes(registrationRequest.getGrantTypes());
return appRegistrationRequest;
@@ -125,17 +137,25 @@ public static ApplicationRegistrationRequest getApplicationRegistrationRequest(
public static ApplicationUpdateRequest getApplicationUpdateRequest(RegistrationRequest registrationRequest,
boolean useSoftwareIdAsAppName) {
-
- String applicationName = "";
+ String applicationName;
if (useSoftwareIdAsAppName) {
- applicationName = registrationRequest.getSoftwareStatementBody().getSoftwareId();
+ applicationName = (registrationRequest.getSoftwareStatement() != null) ?
+ registrationRequest.getSoftwareStatementBody().getSoftwareId():
+ registrationRequest.getSoftwareId();
} else {
applicationName = RegistrationUtils.getSafeApplicationName(
registrationRequest.getSoftwareStatementBody().getClientName());
}
+
ApplicationUpdateRequest applicationUpdateRequest = new ApplicationUpdateRequest();
applicationUpdateRequest.setClientName(applicationName);
- applicationUpdateRequest.setRedirectUris(registrationRequest.getSoftwareStatementBody().getCallbackUris());
+
+ // Set the redirect URIs based on the presence of the software statement
+ applicationUpdateRequest.setRedirectUris(
+ StringUtils.isBlank(registrationRequest.getSoftwareStatement()) ?
+ registrationRequest.getCallbackUris() :
+ registrationRequest.getSoftwareStatementBody().getCallbackUris());
+
applicationUpdateRequest.setGrantTypes(registrationRequest.getGrantTypes());
return applicationUpdateRequest;
@@ -200,19 +220,14 @@ public static Map getAlteredApplicationAttributes(RegistrationRe
throws ParseException {
Map alteredAppAttributeMap = new HashMap<>();
- JsonElement registrationRequestDetails = gson.toJsonTree(registrationRequest);
- Map appAttributeMap = (Map)
- gson.fromJson(registrationRequestDetails, Map.class);
- appAttributeMap.remove("softwareStatementBody");
- appAttributeMap.remove("requestParameters");
- appAttributeMap.remove("ssaParameters");
- addAttributes(appAttributeMap, alteredAppAttributeMap);
- //add ssa attributes
-
- addAttributes(registrationRequest.getSsaParameters(), alteredAppAttributeMap);
-
- //add ssa issuer
- alteredAppAttributeMap.put("ssaIssuer", registrationRequest.getSsaParameters().get("iss").toString());
+ addAttributes(registrationRequest.getRequestParameters(), alteredAppAttributeMap);
+
+ if (registrationRequest.getSoftwareStatement() != null){
+ //add ssa attributes
+ addAttributes(registrationRequest.getSsaParameters(), alteredAppAttributeMap);
+ //add ssa issuer
+ alteredAppAttributeMap.put("ssaIssuer", registrationRequest.getSsaParameters().get("iss").toString());
+ }
return alteredAppAttributeMap;
}
From 493c35e9ce0513fa2455a6659b396666f9353507 Mon Sep 17 00:00:00 2001
From: kalpana
Date: Wed, 15 May 2024 12:24:43 +0530
Subject: [PATCH 149/281] Commits of vrp submission flow
---
.../common/util/ErrorConstants.java | 54 ++-
.../impl/DefaultConsentValidator.java | 118 ++---
.../impl/VRPSubmissionPayloadValidator.java | 432 +++++++++++++-----
.../validate/util/ConsentValidatorUtil.java | 94 ++--
4 files changed, 439 insertions(+), 259 deletions(-)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java
index c28a6c46..4f29b3a1 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java
@@ -1,13 +1,13 @@
/**
* Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
- *
+ *
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -142,7 +142,7 @@ public class ErrorConstants {
+ ErrorConstants.PATH_ACCESS_TOKEN;
public static final String PATH_ACCESS_TOKEN = "Header.AccessToken";
public static final String MSG_INVALID_CLIENT_ID = "The client Id related the consent does not match with the " +
- "client id bound to token:" + ErrorConstants.PATH_CLIENT_ID;
+ "client id bound to token:" + ErrorConstants.PATH_CLIENT_ID;
public static final String PATH_CLIENT_ID = "Header.Client-id";
public static final String UNEXPECTED_ERROR = "OB.UnexpectedError";
public static final String INVALID_CONSENT_TYPE = "Invalid Consent Type found in the request";
@@ -162,40 +162,38 @@ public class ErrorConstants {
"initiated amount:" + ErrorConstants.PATH_INSTRUCTED_AMOUNT_AMOUNT;
public static final String PATH_INSTRUCTED_AMOUNT_AMOUNT = "Data.Initiation.InstructedAmount.Amount";
public static final String INSTRUCTED_AMOUNT_AMOUNT_NOT_FOUND = "Instructed Amount Amount isn't present in the " +
- "payload:" + ErrorConstants.PATH_INSTRUCTED_AMOUNT;
+ "payload:";
public static final String INSTRUCTED_AMOUNT_CURRENCY_MISMATCH = "Instructed Amount currency does not match the " +
"initiated amount or currency:" + ErrorConstants.PATH_INSTRUCTED_AMOUNT_CURRENCY;
public static final String PATH_INSTRUCTED_AMOUNT_CURRENCY = "Data.Initiation.InstructedAmount.Currency";
public static final String INSTRUCTED_AMOUNT_CURRENCY_NOT_FOUND = "Instructed Amount Currency isn't present in " +
- "the payload:" + ErrorConstants.PATH_INSTRUCTED_AMOUNT;
- public static final String INSTRUCTED_AMOUNT_NOT_FOUND = "Instructed Amount isn't present in the payload:" +
- ErrorConstants.PATH_INSTRUCTED_AMOUNT;
+ "the payload:";
+ public static final String INSTRUCTED_AMOUNT_NOT_FOUND = "Instructed Amount isn't present in the payload";
public static final String CREDITOR_ACC_SCHEME_NAME_MISMATCH = "Creditor Accounts Scheme does not match";
public static final String CREDITOR_ACC_SCHEME_NAME_NOT_FOUND = "Creditor Accounts Scheme isn't present in the" +
" request or in the consent.";
public static final String CREDITOR_ACC_IDENTIFICATION_MISMATCH = "Creditor Account Identification does not match";
public static final String CREDITOR_ACC_IDENTIFICATION_NOT_FOUND = "Creditor Account Identification isn't " +
"present in the request or in the consent.";
- public static final String CREDITOR_ACC_NAME_MISMATCH = "Creditor Account Name does not match:";
+ public static final String CREDITOR_ACC_NAME_MISMATCH = "Creditor Account Name does not match";
public static final String CREDITOR_ACC_SEC_IDENTIFICATION_MISMATCH = "Creditor Account Secondary Identification" +
- " does not match:";
+ " does not match";
public static final String DEBTOR_ACC_SCHEME_NAME_MISMATCH = "Debtor Account Scheme name does not ";
public static final String DEBTOR_ACC_SCHEME_NAME_NOT_FOUND = "Debtor Account Scheme name isn't present in the " +
- "request or in the consent:";
+ "request or in the consent";
public static final String DEBTOR_ACC_IDENTIFICATION_MISMATCH = "Debtor Account Identification does " +
"not match:";
public static final String DEBTOR_ACC_IDENTIFICATION_NOT_FOUND = "Debtor Account Identification isn't present " +
- "in the request or in the consent:";
+ "in the request or in the consent";
public static final String DEBTOR_ACC_NAME_MISMATCH = "Debtor Account Name does not match";
public static final String DEBTOR_ACC_SEC_IDENTIFICATION_MISMATCH = "Debtor Account Secondary Identification" +
- " does not match:";
+ " does not match";
public static final String PATH_DEBTOR_ACCOUNT_SECOND_IDENTIFICATION =
"Data.Initiation.DebtorAccount.SecondaryIdentification";
public static final String CREDITOR_ACC_NOT_FOUND = "Creditor Account isn't present in the request.";
- public static final String DEBTOR_ACC_MISMATCH = "Debtor Account isn't present in the request " +
- "or in the consent:";
- public static final String LOCAL_INSTRUMENT_MISMATCH = "Local Instrument Does Not Match:" +
+ public static final String DEBTOR_ACC_MISMATCH = "Debtor Account mismatch";
+ public static final String LOCAL_INSTRUMENT_MISMATCH = "Local Instrument Does Not Match" +
ErrorConstants.PATH_LOCAL_INSTRUMENT;
public static final String TOKEN_REVOKE_ERROR = "Token revocation unsuccessful. :" +
ErrorConstants.PATH_CUTOFF_DATE;
@@ -267,7 +265,6 @@ public class ErrorConstants {
public static final String DATE_INVALID_PARAMETER_MESSAGE = "Invalid date-time range for ValidToDateTime ";
-
// vrp path parameters
public static final String PATH_VALID_TO_DATE = "Data.ControlParameters.ValidToDateTime";
public static final String PATH_VALID_FROM_DATE = "Data.ControlParameters.ValidFromDateTime";
@@ -290,7 +287,7 @@ public class ErrorConstants {
// VRP Submission flow
public static final String REMITTANCE_INFO_NOT_FOUND = "Remittance info is not present in the request.";
- public static final String INSTRUCTION_IDENTIFICATION_NOT_FOUND = "Instruction Identification isn't present" +
+ public static final String INSTRUCTION_IDENTIFICATION_NOT_FOUND = "Instruction Identification isn't present" +
" in the request";
public static final String END_TO_END_IDENTIFICATION_PARAMETER_NOT_FOUND = "End to End Identification isn't" +
" present in the request";
@@ -307,11 +304,11 @@ public class ErrorConstants {
"not a String instance";
public static final String INVALID_TYPE = "Value associated with END_TO_END_IDENTIFICATION key is " +
"not a String instance";
- public static final String RISK_NOT_FOUND = "Risk is not found or empty in the request or it is not in the" +
- " correct JSON format.";
+ public static final String RISK_NOT_FOUND = "Risk is not found or empty in the request.";
+ public static final String RISK_NOT_JSON_ERROR = "Risk parameter is not in the correct JSON format";
public static final String INSTRUCTION_NOT_FOUND = "Instruction is not found or empty in the request.";
- public static final String INVALID_REQUEST_CONSENT_ID = "The requested consent-Id is not present in the request" +
- "or it is not in the correct JSON format";
+ public static final String INVALID_REQUEST_CONSENT_ID = "The consent-Id is not present in the request" +
+ " or it is not a String instance or there is a consentId mismatch";
public static final String INSTRUCTION_CREDITOR_ACC_NOT_JSON_ERROR = "Creditor Account present under instruction" +
" isn't present in the correct JSON format in the request.";
public static final String INITIATION_CREDITOR_ACC_NOT_JSON_ERROR = "Creditor Account present under initiation" +
@@ -322,5 +319,16 @@ public class ErrorConstants {
"present in the correct JSON format in the request.";
public static final String INSTRUCTION_REMITTANCE_INFO_NOT_JSON_ERROR = "Remittance info of instruction is not" +
" present in the correct JSON format in the request.";
+ public static final String DEBTOR_ACC_NOT_FOUND = "Debtor Account isn't present in the request.";
+ public static final String DATA_NOT_JSON_ERROR = "Data parameter is not in the correct JSON format in the request";
+ public static final String INSTRUCTED_AMOUNT_NOT_STRING = "Value associated with Amount key is " +
+ "not a String instance";
+ public static final String INSTRUCTED_AMOUNT_CURRENCY_NOT_STRING = "Value associated with Currency key is " +
+ "not a String instance";
+ public static final String INSTRUCTED_AMOUNT_NOT_JSON_ERROR = "Instructed Amount is not in the correct JSON " +
+ "format in the request";
+ public static final String INITIATION_NOT_JSON = "Initiation is not in the correct JSON " +
+ "format in the request";
+ public static final String INSTRUCTION_NOT_JSON = "Instruction is not in the correct JSON format in the request";
}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/DefaultConsentValidator.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/DefaultConsentValidator.java
index 9c2b8fa9..faab62fe 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/DefaultConsentValidator.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/DefaultConsentValidator.java
@@ -1,13 +1,13 @@
/**
* Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
- *
+ *
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
diff --git a/react-apps/self-care-portal/self-care-portal-frontend/accelerator/src/specConfigs/common.js b/react-apps/self-care-portal/self-care-portal-frontend/accelerator/src/specConfigs/common.js
index 37c014fc..9d5b9f94 100644
--- a/react-apps/self-care-portal/self-care-portal-frontend/accelerator/src/specConfigs/common.js
+++ b/react-apps/self-care-portal/self-care-portal-frontend/accelerator/src/specConfigs/common.js
@@ -17,7 +17,7 @@
*/
export const common = {
- footerContent: "WSO2 Open Banking | 2021",
+ footerContent: "WSO2 Open Banking | " + new Date().getFullYear(),
complaintHandleLinkText: "Complaint handling and resolution",
};
diff --git a/react-apps/self-care-portal/self-care-portal-frontend/accelerator/src/specConfigs/specConfigurations.js b/react-apps/self-care-portal/self-care-portal-frontend/accelerator/src/specConfigs/specConfigurations.js
index ff500410..571c75f8 100644
--- a/react-apps/self-care-portal/self-care-portal-frontend/accelerator/src/specConfigs/specConfigurations.js
+++ b/react-apps/self-care-portal/self-care-portal-frontend/accelerator/src/specConfigs/specConfigurations.js
@@ -173,7 +173,7 @@ export const account_lang = [
},
],
profile: {
- confirmation: "View confirmation of consent >"
+ confirmation: "Download confirmation of consent"
},
keyDatesInfoLabel: "Key Dates",
keyDates: [
From 260e508da50ed60b02dc3fd2f2d27107b59691d2 Mon Sep 17 00:00:00 2001
From: ImalshaD
Date: Tue, 21 May 2024 13:06:03 +0530
Subject: [PATCH 187/281] Digest validation logic added.
---
.../accelerator/common/util/JWTUtils.java | 35 ++++---
.../common/test/util/JWTUtilsTest.java | 18 ++--
...der.java => JWTUtilsTestDataProvider.java} | 3 +-
.../app2app/App2AppAuthenticator.java | 34 ++++---
.../App2AppAuthenticatorConstants.java | 1 +
.../model/DeviceVerificationToken.java | 20 +++-
.../DeviceVerificationTokenConstants.java | 3 +-
.../app2app/utils/App2AppAuthUtils.java | 63 +++---------
.../app2app/validations/DigestValidator.java | 99 +++++++++++++++++++
.../app2app/validations/ExpiryValidator.java | 2 +-
.../app2app/validations/JTIValidator.java | 2 +-
.../app2app/validations/NBFValidator.java | 4 +-
.../PublicKeySignatureValidator.java | 5 +-
.../annotations/ValidateDigest.java | 48 +++++++++
.../annotations/ValidateExpiry.java | 2 +-
.../validations/annotations/ValidateJTI.java | 2 +-
.../validations/annotations/ValidateNBF.java | 2 +-
.../annotations/ValidateSignature.java | 2 +-
.../app2app/App2AppAuthUtilsTest.java | 2 +-
.../app2app/App2AppAuthValidationTest.java | 61 +++++++++---
.../app2app/App2AppAuthenticatorTest.java | 3 -
.../App2AppAuthenticatorTestDataProvider.java | 13 ++-
.../app2app/testutils/JWTDataProvider.java | 54 ++++++++--
23 files changed, 347 insertions(+), 131 deletions(-)
rename open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/testutils/{JWTUtilsDataProvider.java => JWTUtilsTestDataProvider.java} (99%)
create mode 100644 open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/DigestValidator.java
create mode 100644 open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateDigest.java
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/JWTUtils.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/JWTUtils.java
index 12ab7334..02781907 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/JWTUtils.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/JWTUtils.java
@@ -36,6 +36,7 @@
import com.nimbusds.jwt.proc.DefaultJWTProcessor;
import com.wso2.openbanking.accelerator.common.config.OpenBankingConfigParser;
import com.wso2.openbanking.accelerator.common.constant.OpenBankingConstants;
+import com.wso2.openbanking.accelerator.common.exception.OpenBankingException;
import net.minidev.json.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
@@ -60,6 +61,8 @@
public class JWTUtils {
private static final Log log = LogFactory.getLog(JWTUtils.class);
+ private static final String RS = "RS";
+ private static final String ALGORITHM_RSA = "RSA";
/**
* Decode request JWT.
@@ -135,7 +138,7 @@ public static boolean validateJWTSignature(String jwtString, String jwksUri, Str
}
/**
- *Validates the signature of a given JWT against a given public key.
+ * Validates the signature of a given JWT against a given public key.
*
* @param signedJWT the signed JWT to be validated
* @param publicKey the public key that is used for validation
@@ -146,23 +149,29 @@ public static boolean validateJWTSignature(String jwtString, String jwksUri, Str
*/
@Generated(message = "Excluding from code coverage as KeyFactory does not initialize")
public static boolean validateJWTSignature(SignedJWT signedJWT, String publicKey)
- throws NoSuchAlgorithmException, InvalidKeySpecException, JOSEException {
+ throws NoSuchAlgorithmException, InvalidKeySpecException, JOSEException, OpenBankingException {
byte[] publicKeyData = Base64.getDecoder().decode(publicKey);
X509EncodedKeySpec spec = new X509EncodedKeySpec(publicKeyData);
- String algorithm = signedJWT.getHeader().getAlgorithm().toString();
- KeyFactory kf = KeyFactory.getInstance(algorithm);
+ String algorithm = signedJWT.getHeader().getAlgorithm().getName();
+ KeyFactory kf;
+ if (algorithm.indexOf(RS) == 0) {
+ kf = KeyFactory.getInstance(ALGORITHM_RSA);
+ } else {
+ throw new OpenBankingException("Algorithm " + algorithm + "not yet supported.");
+ }
RSAPublicKey rsapublicKey = (RSAPublicKey) kf.generatePublic(spec);
JWSVerifier verifier = new RSASSAVerifier(rsapublicKey);
return signedJWT.verify(verifier);
}
/**
- * Validate legitimacy of JWT.
+ * Validate legitimacy of a JWS.
*
* @param jwsString JWT string
+ * @return true if a given jwsString adheres a valid JWS Format
*/
- public static boolean isJWT(String jwsString) {
+ public static boolean isValidJWSFormat(String jwsString) {
return StringUtils.isBlank(jwsString) ? false :
StringUtils.countMatches(jwsString, OpenBankingConstants.DOT_SEPARATOR) == 2;
@@ -174,11 +183,11 @@ public static boolean isJWT(String jwsString) {
* @param jwtString the JWT string to parse
* @return the parsed SignedJWT object
* @throws IllegalArgumentException if the provided token identifier is not a parsable JWT
- * Will not throw ParseException as it is already validated by isJWT
+ *
*/
public static SignedJWT getSignedJWT(String jwtString) throws ParseException {
- if (isJWT(jwtString)) {
+ if (isValidJWSFormat(jwtString)) {
return SignedJWT.parse(jwtString);
} else {
if (log.isDebugEnabled()) {
@@ -189,11 +198,11 @@ public static SignedJWT getSignedJWT(String jwtString) throws ParseException {
}
/**
- * Validates whether a given JWT is not expired.
+ * Checks if the given expiration time is valid based on the current system time and a default time skew.
*
* @param defaultTimeSkew defaultTimeSkew to adjust latency issues.
* @param expirationTime the exp of the jwt that should be validated.
- * @return true if the jwt is not expired
+ * @return True if the expiration time is valid considering the default time skew; false otherwise.
*/
public static boolean isValidExpiryTime(Date expirationTime, long defaultTimeSkew) {
@@ -208,13 +217,13 @@ public static boolean isValidExpiryTime(Date expirationTime, long defaultTimeSke
}
/**
- * Validates whether a given JWT is active.
+ * Checks if the given "not before" time is valid based on the current system time and a default time skew.
*
* @param defaultTimeSkew defaultTimeSkew to adjust latency issues.
* @param notBeforeTime nbf of the jwt that should be validated
- * @return true if the jwt is active
+ * @return True if the "not before" time is valid considering the default time skew; false otherwise.
*/
- public static boolean isvalidNotValidBeforeTime(Date notBeforeTime, long defaultTimeSkew) {
+ public static boolean isValidNotValidBeforeTime(Date notBeforeTime, long defaultTimeSkew) {
if (notBeforeTime != null) {
long timeStampSkewMillis = defaultTimeSkew * 1000;
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/JWTUtilsTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/JWTUtilsTest.java
index 17d06f5c..0658d00c 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/JWTUtilsTest.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/JWTUtilsTest.java
@@ -18,7 +18,7 @@
package com.wso2.openbanking.accelerator.common.test.util;
-import com.wso2.openbanking.accelerator.common.test.util.testutils.JWTUtilsDataProvider;
+import com.wso2.openbanking.accelerator.common.test.util.testutils.JWTUtilsTestDataProvider;
import com.wso2.openbanking.accelerator.common.util.JWTUtils;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -31,42 +31,42 @@
*/
public class JWTUtilsTest {
- @Test(dataProviderClass = JWTUtilsDataProvider.class, dataProvider = "jwtStrings")
+ @Test(dataProviderClass = JWTUtilsTestDataProvider.class, dataProvider = "jwtStrings")
public void testIsJWT(String jwtString, boolean expected) {
- Assert.assertEquals(JWTUtils.isJWT(jwtString), expected);
+ Assert.assertEquals(JWTUtils.isValidJWSFormat(jwtString), expected);
}
- @Test(dataProviderClass = JWTUtilsDataProvider.class, dataProvider = "validParsableJwtStrings")
+ @Test(dataProviderClass = JWTUtilsTestDataProvider.class, dataProvider = "validParsableJwtStrings")
public void testGetSignedJWT(String jwtString) throws ParseException {
Assert.assertNotNull(JWTUtils.getSignedJWT(jwtString));
}
@Test(expectedExceptions = ParseException.class,
- dataProviderClass = JWTUtilsDataProvider.class, dataProvider = "validNotParsableJwtStrings")
+ dataProviderClass = JWTUtilsTestDataProvider.class, dataProvider = "validNotParsableJwtStrings")
public void testGetSignedJWTWIthNotParsableJWT(String jwtString) throws ParseException {
JWTUtils.getSignedJWT(jwtString);
}
@Test(expectedExceptions = IllegalArgumentException.class,
- dataProviderClass = JWTUtilsDataProvider.class, dataProvider = "notValidJwtStrings")
+ dataProviderClass = JWTUtilsTestDataProvider.class, dataProvider = "notValidJwtStrings")
public void testGetSignedJWTWIthNotValidJWT(String jwtString) throws ParseException {
JWTUtils.getSignedJWT(jwtString);
}
- @Test(dataProviderClass = JWTUtilsDataProvider.class, dataProvider = "expiryTimeProvider")
+ @Test(dataProviderClass = JWTUtilsTestDataProvider.class, dataProvider = "expiryTimeProvider")
public void testValidExpirationTime(Date time, long timeSkew, boolean expected) {
Assert.assertEquals(JWTUtils.isValidExpiryTime(time, timeSkew), expected);
}
- @Test(dataProviderClass = JWTUtilsDataProvider.class, dataProvider = "nbfProvider")
+ @Test(dataProviderClass = JWTUtilsTestDataProvider.class, dataProvider = "nbfProvider")
public void testValidNotValidBefore(Date time, long timeSkew, boolean expected) {
- Assert.assertEquals(JWTUtils.isvalidNotValidBeforeTime(time, timeSkew), expected);
+ Assert.assertEquals(JWTUtils.isValidNotValidBeforeTime(time, timeSkew), expected);
}
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/testutils/JWTUtilsDataProvider.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/testutils/JWTUtilsTestDataProvider.java
similarity index 99%
rename from open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/testutils/JWTUtilsDataProvider.java
rename to open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/testutils/JWTUtilsTestDataProvider.java
index 88d8205d..c1ef208f 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/testutils/JWTUtilsDataProvider.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/test/java/com/wso2/openbanking/accelerator/common/test/util/testutils/JWTUtilsTestDataProvider.java
@@ -25,9 +25,10 @@
/**
* Data Provider for JWTUtilsTest.
*/
-public class JWTUtilsDataProvider {
+public class JWTUtilsTestDataProvider {
@DataProvider(name = "jwtStrings")
+
public Object[][] getJwtStrings() {
return new Object[][] {
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticator.java
index e0541803..1b79fa52 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticator.java
@@ -84,6 +84,8 @@ protected void processAuthenticationResponse(HttpServletRequest httpServletReque
authenticationContext.setCurrentAuthenticator(App2AppAuthenticatorConstants.AUTHENTICATOR_NAME);
String jwtString =
httpServletRequest.getParameter(App2AppAuthenticatorConstants.DEVICE_VERIFICATION_TOKEN_IDENTIFIER);
+ String request =
+ httpServletRequest.getParameter(App2AppAuthenticatorConstants.REQUEST);
try {
SignedJWT signedJWT = JWTUtils.getSignedJWT(jwtString);
@@ -94,6 +96,9 @@ protected void processAuthenticationResponse(HttpServletRequest httpServletReque
//Checking whether deviceId and loginHint present in passed jwt
if (StringUtils.isBlank(loginHint) || StringUtils.isBlank(deviceID)) {
+ if (log.isDebugEnabled()) {
+ log.debug(App2AppAuthenticatorConstants.REQUIRED_PRAMAS_MISSING_MESSAGE);
+ }
throw new AuthenticationFailedException(App2AppAuthenticatorConstants.REQUIRED_PRAMAS_MISSING_MESSAGE);
}
@@ -101,6 +106,7 @@ protected void processAuthenticationResponse(HttpServletRequest httpServletReque
App2AppAuthUtils.getAuthenticatedUserFromSubjectIdentifier(loginHint);
String publicKey = getPublicKeyByDeviceID(deviceID, userToBeAuthenticated);
deviceVerificationToken.setPublicKey(publicKey);
+ deviceVerificationToken.setRequestObject(request);
// setting the user is mandatory for data publishing purposes
//If exception is thrown before setting a user data publishing will encounter exceptions
authenticationContext.setSubject(userToBeAuthenticated);
@@ -110,29 +116,27 @@ protected void processAuthenticationResponse(HttpServletRequest httpServletReque
*/
App2AppAuthUtils.validateToken(deviceVerificationToken);
//If the flow is not interrupted user will be authenticated.
- log.info(String.format(App2AppAuthenticatorConstants.USER_AUTHENTICATED_MSG,
- userToBeAuthenticated.getUserName()));
+ if (log.isDebugEnabled()) {
+ log.debug(String.format(App2AppAuthenticatorConstants.USER_AUTHENTICATED_MSG,
+ userToBeAuthenticated.getUserName()));
+ }
} catch (ParseException e) {
- throw new AuthenticationFailedException
- (App2AppAuthenticatorConstants.PARSE_EXCEPTION_MESSAGE + e.getMessage(), e);
+ throw new AuthenticationFailedException(App2AppAuthenticatorConstants.PARSE_EXCEPTION_MESSAGE, e);
} catch (JWTValidationException e) {
- throw new AuthenticationFailedException
- (App2AppAuthenticatorConstants.JWT_VALIDATION_EXCEPTION_MESSAGE + e.getMessage(), e);
+ throw new AuthenticationFailedException(App2AppAuthenticatorConstants.JWT_VALIDATION_EXCEPTION_MESSAGE, e);
} catch (OpenBankingException e) {
- throw new AuthenticationFailedException
- (App2AppAuthenticatorConstants.OPEN_BANKING_EXCEPTION_MESSAGE + e.getMessage(), e);
+ throw new AuthenticationFailedException(App2AppAuthenticatorConstants.OPEN_BANKING_EXCEPTION_MESSAGE, e);
} catch (PushDeviceHandlerServerException e) {
throw new AuthenticationFailedException
- (App2AppAuthenticatorConstants.PUSH_DEVICE_HANDLER_SERVER_EXCEPTION_MESSAGE + e.getMessage(), e);
+ (App2AppAuthenticatorConstants.PUSH_DEVICE_HANDLER_SERVER_EXCEPTION_MESSAGE, e);
} catch (UserStoreException e) {
- throw new AuthenticationFailedException
- (App2AppAuthenticatorConstants.USER_STORE_EXCEPTION_MESSAGE + e.getMessage(), e);
+ throw new AuthenticationFailedException(App2AppAuthenticatorConstants.USER_STORE_EXCEPTION_MESSAGE, e);
} catch (PushDeviceHandlerClientException e) {
throw new AuthenticationFailedException
- (App2AppAuthenticatorConstants.PUSH_DEVICE_HANDLER_CLIENT_EXCEPTION_MESSAGE + e.getMessage(), e);
+ (App2AppAuthenticatorConstants.PUSH_DEVICE_HANDLER_CLIENT_EXCEPTION_MESSAGE, e);
} catch (IllegalArgumentException e) {
- throw new AuthenticationFailedException
- (App2AppAuthenticatorConstants.ILLEGAL_ARGUMENT_EXCEPTION_MESSAGE + e.getMessage(), e);
+ throw new
+ AuthenticationFailedException(App2AppAuthenticatorConstants.ILLEGAL_ARGUMENT_EXCEPTION_MESSAGE, e);
}
}
@@ -146,7 +150,7 @@ public boolean canHandle(HttpServletRequest httpServletRequest) {
App2App authenticates the user in one step depending on the app_auth_key,
Hence it's mandatory to have the required parameter app_auth_key.
*/
- return !StringUtils.isBlank(httpServletRequest.getParameter(
+ return StringUtils.isNotBlank(httpServletRequest.getParameter(
App2AppAuthenticatorConstants.DEVICE_VERIFICATION_TOKEN_IDENTIFIER));
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorConstants.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorConstants.java
index 0cbcacbf..ab9b6175 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorConstants.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorConstants.java
@@ -25,6 +25,7 @@ public class App2AppAuthenticatorConstants {
public static final String AUTHENTICATOR_NAME = "app2app";
public static final String AUTHENTICATOR_FRIENDLY_NAME = "App2App Authenticator";
+ public static final String REQUEST = "request";
public static final String DEVICE_VERIFICATION_TOKEN_IDENTIFIER = "deviceVerificationToken";
public static final String SESSION_DATA_KEY = "sessionDataKey";
public static final String JWT_VALIDATION_EXCEPTION_MESSAGE = "Error while validating JWT: ";
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/DeviceVerificationToken.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/DeviceVerificationToken.java
index a32a9689..f977d161 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/DeviceVerificationToken.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/DeviceVerificationToken.java
@@ -21,6 +21,7 @@
import com.google.gson.annotations.SerializedName;
import com.nimbusds.jwt.JWTClaimsSet;
import com.nimbusds.jwt.SignedJWT;
+import com.wso2.openbanking.accelerator.identity.app2app.validations.annotations.ValidateDigest;
import com.wso2.openbanking.accelerator.identity.app2app.validations.annotations.ValidateExpiry;
import com.wso2.openbanking.accelerator.identity.app2app.validations.annotations.ValidateJTI;
import com.wso2.openbanking.accelerator.identity.app2app.validations.annotations.ValidateNBF;
@@ -42,6 +43,7 @@
@ValidateSignature(groups = SignatureCheck.class)
@ValidateExpiry(groups = ValidityChecks.class)
@ValidateNBF(groups = ValidityChecks.class)
+@ValidateDigest(groups = ValidityChecks.class)
public class DeviceVerificationToken {
@SerializedName(DeviceVerificationTokenConstants.DEVICE_IDENTIFIER)
@@ -56,8 +58,11 @@ public class DeviceVerificationToken {
private String jti;
@SerializedName(DeviceVerificationTokenConstants.ISSUED_TIME)
private Date issuedTime;
+ @SerializedName(DeviceVerificationTokenConstants.DIGEST)
+ private String digest;
private SignedJWT signedJWT;
private String publicKey;
+ private String requestObject;
public DeviceVerificationToken(SignedJWT signedJWT)
throws ParseException {
@@ -70,7 +75,7 @@ public DeviceVerificationToken(SignedJWT signedJWT)
this.jti = jwtClaimsSet.getJWTID();
this.deviceId = getClaim(jwtClaimsSet, DeviceVerificationTokenConstants.DEVICE_IDENTIFIER);
this.loginHint = getClaim(jwtClaimsSet, DeviceVerificationTokenConstants.LOGIN_HINT);
-
+ this.digest = getClaim(jwtClaimsSet, DeviceVerificationTokenConstants.DIGEST);
}
@NotBlank(message = "Required parameter did cannot be null or empty.", groups = MandatoryChecks.class)
@@ -131,6 +136,11 @@ public void setPublicKey(String publicKey) {
this.publicKey = publicKey;
}
+ public String getDigest() {
+
+ return this.digest;
+ }
+
/**
* Retrieves the value of the specified claim from the provided JWTClaimsSet.
*
@@ -143,5 +153,13 @@ private String getClaim(JWTClaimsSet jwtClaimsSet , String claim) {
Object claimObj = jwtClaimsSet.getClaim(claim);
return (String) claimObj;
}
+
+ public String getRequestObject() {
+ return requestObject;
+ }
+
+ public void setRequestObject(String requestObject) {
+ this.requestObject = requestObject;
+ }
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/DeviceVerificationTokenConstants.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/DeviceVerificationTokenConstants.java
index a5a07de9..c5c81664 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/DeviceVerificationTokenConstants.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/model/DeviceVerificationTokenConstants.java
@@ -25,9 +25,10 @@ public class DeviceVerificationTokenConstants {
public static final String EXPIRY_TIME = "exp";
public static final String NOT_VALID_BEFORE = "nbf";
- public static final String LOGIN_HINT = "loginHint";
+ public static final String LOGIN_HINT = "login_hint";
public static final String ISSUED_TIME = "ist";
public static final String DEVICE_IDENTIFIER = "did";
public static final String JWT_ID = "jti";
+ public static final String DIGEST = "digest";
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/utils/App2AppAuthUtils.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/utils/App2AppAuthUtils.java
index f702b44a..ec1efd4f 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/utils/App2AppAuthUtils.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/utils/App2AppAuthUtils.java
@@ -37,7 +37,6 @@
import org.wso2.carbon.user.core.service.RealmService;
import java.util.List;
-import java.util.Optional;
/**
* Utils class for Authentication related logic implementations.
@@ -96,64 +95,34 @@ public static String getUserIdFromUsername(String username, UserRealm userRealm)
}
/**
- * Retrieves the registered device associated with the specified device ID and user ID.
+ * Retrieve Public key of the device specified if it is registered under specified user.
* TODO: Optimise this code to retrieve device by did and validate userID.
* Github issue :{...}
*
- * @param deviceId the ID of the device to retrieve
- * @param userId the ID of the user who owns the device
- * @return the registered device associated with the specified IDs
+ * @param deviceId deviceId of the device where the public key is required
+ * @param userId userId of the user
+ * @return the public key of the intended device.
* @throws PushDeviceHandlerServerException if an error occurs on the server side while handling the device
* @throws IllegalArgumentException if the provided device identifier does not exist
* @throws PushDeviceHandlerClientException if an error occurs on the client side while handling the device
*/
- public static Device getRegisteredDevice(String deviceId, String userId, DeviceHandler deviceHandler)
- throws PushDeviceHandlerServerException, IllegalArgumentException,
- PushDeviceHandlerClientException, OpenBankingException {
+ public static String getPublicKey(String deviceId, String userId, DeviceHandler deviceHandler)
+ throws PushDeviceHandlerServerException, IllegalArgumentException, PushDeviceHandlerClientException,
+ OpenBankingException {
/*
It is important to verify the device is registered under the given user
as public key is associated with device not the user.
*/
List deviceList = deviceHandler.listDevices(userId);
- //If a device registered under the given user matches the specified deviceId return the device
- Optional optionalDevice = deviceList.stream()
- .filter(device -> StringUtils.equals(device.getDeviceId(), deviceId))
- .findFirst();
- //If no device found throw exception
- Device device = optionalDevice.orElseThrow(() ->
- new OpenBankingException("Provided Device ID doesn't match any device registered under user."));
- //If a device is found set the public key
- device.setPublicKey(deviceHandler.getPublicKey(deviceId));
- return device;
- }
-
- /**
- * Retrieves the public key associated with the specified device.
- *
- * @param device the device from which to retrieve the public key
- * @return the public key associated with the device
- */
- public static String getPublicKeyFromDevice(Device device) {
-
- return device.getPublicKey();
- }
-
- /**
- * Retrieve Public key of the device specified if it is registered under specified user.
- *
- * @param deviceID deviceID of the device where the public key is required
- * @param userID userID of the user
- * @return the public key
- * @throws PushDeviceHandlerServerException if an error occurs on the server side while handling the device
- * @throws IllegalArgumentException if the provided device identifier does not exist
- * @throws PushDeviceHandlerClientException if an error occurs on the client side while handling the device
- */
- public static String getPublicKey(String deviceID, String userID, DeviceHandler deviceHandler)
- throws PushDeviceHandlerServerException, IllegalArgumentException, PushDeviceHandlerClientException,
- OpenBankingException {
-
- return getPublicKeyFromDevice(getRegisteredDevice(deviceID, userID, deviceHandler));
+ //If none of the devices registered under the given user matches the specified deviceId then throw a exception
+ deviceList.stream()
+ .filter(registredDevice -> StringUtils.equals(registredDevice.getDeviceId(), deviceId))
+ .findFirst()
+ .orElseThrow(() ->
+ new OpenBankingException("Provided Device ID doesn't match any device registered under user."));
+ //If a device is found retrieve and return the public key
+ return deviceHandler.getPublicKey(deviceId);
}
/**
@@ -166,7 +135,7 @@ public static void validateToken(DeviceVerificationToken deviceVerificationToken
/*
App2AppValidationOrder validation order
1.Required Params validation
- 2.Validity Validations - Signature, JTI, Timeliness will be validated.
+ 2.Validity Validations - Signature, JTI, Timeliness, Digest will be validated.
*/
String error = OpenBankingValidator.getInstance()
.getFirstViolation(deviceVerificationToken, App2AppValidationOrder.class);
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/DigestValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/DigestValidator.java
new file mode 100644
index 00000000..8ebe08b4
--- /dev/null
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/DigestValidator.java
@@ -0,0 +1,99 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.openbanking.accelerator.identity.app2app.validations;
+
+import com.wso2.openbanking.accelerator.identity.app2app.model.DeviceVerificationToken;
+import com.wso2.openbanking.accelerator.identity.app2app.validations.annotations.ValidateDigest;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Base64;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * Validator class for validating digest of a device verification token.
+ */
+public class DigestValidator implements ConstraintValidator {
+
+ private static final Log log = LogFactory.getLog(DigestValidator.class);
+
+ /**
+ * Checks if the given device verification token is valid based on its digest.
+ *
+ * @param deviceVerificationToken The device verification token to be validated.
+ * @param constraintValidatorContext The context in which the validation is performed.
+ * @return true if the token is valid, false otherwise.
+ */
+ @Override
+ public boolean isValid(DeviceVerificationToken deviceVerificationToken,
+ ConstraintValidatorContext constraintValidatorContext) {
+
+ String requestObject = deviceVerificationToken.getRequestObject();
+ String digest = deviceVerificationToken.getDigest();
+ return validateDigest(digest, requestObject);
+ }
+
+ /**
+ * Validating the digest of the request.
+ *
+ * @param digestHeader digest header sent with the request
+ * @param request the request JWT String
+ * @return return true if the digest validation is a success, false otherwise
+ */
+ protected boolean validateDigest(String digestHeader, String request) {
+
+ if (StringUtils.isBlank(request)) {
+ //If the request is null nothing to validate.
+ return true;
+ } else if (StringUtils.isBlank(digestHeader)) {
+ //If request is not empty and digest us empty validation fails.
+ return false;
+ }
+
+ try {
+ String[] digestAttribute = digestHeader.split("=", 2);
+ if (digestAttribute.length != 2) {
+ log.error("Invalid digest header.");
+ return false;
+ }
+ String digestAlgorithm = digestAttribute[0].trim();
+ String digestValue = digestAttribute[1].trim();
+ MessageDigest messageDigest = MessageDigest.getInstance(digestAlgorithm);
+ byte[] digestHash = messageDigest.digest(request.getBytes(StandardCharsets.UTF_8));
+ String generatedDigest = Base64.getEncoder()
+ .encodeToString(digestHash);
+
+ if (generatedDigest.equals(digestValue)) {
+ return true;
+ }
+
+ } catch (NoSuchAlgorithmException e) {
+ log.error("Invalid algorithm.", e);
+ return false;
+ }
+
+ return false;
+ }
+}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/ExpiryValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/ExpiryValidator.java
index c8135572..078fb847 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/ExpiryValidator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/ExpiryValidator.java
@@ -28,7 +28,7 @@
import javax.validation.ConstraintValidatorContext;
/**
- * Validator class for validating expiry of a device verification token..
+ * Validator class for validating expiry of a device verification token.
*/
public class ExpiryValidator implements ConstraintValidator {
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JTIValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JTIValidator.java
index 801f5895..960d67fd 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JTIValidator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/JTIValidator.java
@@ -26,7 +26,7 @@
import javax.validation.ConstraintValidatorContext;
/**
- * Validator class for validating the JWT ID of a device verification token..
+ * Validator class for validating the JWT ID of a device verification token.
*/
public class JTIValidator implements ConstraintValidator {
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/NBFValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/NBFValidator.java
index c83a05e3..ff7b6528 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/NBFValidator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/NBFValidator.java
@@ -30,7 +30,7 @@
import javax.validation.ConstraintValidatorContext;
/**
- * Validation class for validating NBF of a device verification token..
+ * Validation class for validating NBF of a device verification token.
*/
public class NBFValidator implements ConstraintValidator {
@@ -49,7 +49,7 @@ public boolean isValid(DeviceVerificationToken deviceVerificationToken,
ConstraintValidatorContext constraintValidatorContext) {
Date notValidBefore = deviceVerificationToken.getNotValidBefore();
- return JWTUtils.isvalidNotValidBeforeTime(notValidBefore, DEFAULT_TIME_SKEW_IN_SECONDS);
+ return JWTUtils.isValidNotValidBeforeTime(notValidBefore, DEFAULT_TIME_SKEW_IN_SECONDS);
}
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/PublicKeySignatureValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/PublicKeySignatureValidator.java
index a8ce36da..d8bb1287 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/PublicKeySignatureValidator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/PublicKeySignatureValidator.java
@@ -20,6 +20,7 @@
import com.nimbusds.jose.JOSEException;
import com.nimbusds.jwt.SignedJWT;
+import com.wso2.openbanking.accelerator.common.exception.OpenBankingException;
import com.wso2.openbanking.accelerator.common.util.JWTUtils;
import com.wso2.openbanking.accelerator.identity.app2app.model.DeviceVerificationToken;
import com.wso2.openbanking.accelerator.identity.app2app.validations.annotations.ValidateSignature;
@@ -65,8 +66,10 @@ public boolean isValid(DeviceVerificationToken deviceVerificationToken,
log.error("Invalid key spec.", e);
return false;
} catch (JOSEException e) {
- log.error("JOSE exception", e);
+ log.error("JOSE exception.", e);
return false;
+ } catch (OpenBankingException e) {
+ log.error("Algorithm not supported yet.", e);
}
return true;
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateDigest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateDigest.java
new file mode 100644
index 00000000..d50243c8
--- /dev/null
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateDigest.java
@@ -0,0 +1,48 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.openbanking.accelerator.identity.app2app.validations.annotations;
+
+import com.wso2.openbanking.accelerator.identity.app2app.validations.DigestValidator;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Annotation class for validating digest.
+ */
+@Target(TYPE)
+@Retention(RUNTIME)
+@Documented
+@Constraint(validatedBy = {DigestValidator.class})
+public @interface ValidateDigest {
+
+ String message() default "Digest validation failed.";
+
+ Class>[] groups() default {};
+
+ Class extends Payload>[] payload() default {};
+}
+
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateExpiry.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateExpiry.java
index 074e456d..44134d4e 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateExpiry.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateExpiry.java
@@ -31,7 +31,7 @@
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Annotation class for validating expiry of a device verification token..
+ * Annotation class for validating expiry of a device verification token.
*/
@Target(TYPE)
@Retention(RUNTIME)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateJTI.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateJTI.java
index 9e7b5b45..24e33d67 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateJTI.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateJTI.java
@@ -31,7 +31,7 @@
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Annotation class for validating JWT ID of a device verification token..
+ * Annotation class for validating JWT ID of a device verification token.
*/
@Target(TYPE)
@Retention(RUNTIME)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateNBF.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateNBF.java
index 45b8f323..c5c6ad02 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateNBF.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateNBF.java
@@ -31,7 +31,7 @@
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Annotation class for validating NBF of a device verification token..
+ * Annotation class for validating NBF of a device verification token.
*/
@Target(TYPE)
@Retention(RUNTIME)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateSignature.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateSignature.java
index 60068a26..beaeb7a8 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateSignature.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/annotations/ValidateSignature.java
@@ -30,7 +30,7 @@
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Annotation class for validating JWT Signature of a device verification token..
+ * Annotation class for validating JWT Signature of a device verification token.
*/
@Target(TYPE)
@Retention(RUNTIME)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthUtilsTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthUtilsTest.java
index 4a8e3099..f3b1b2dd 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthUtilsTest.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthUtilsTest.java
@@ -155,7 +155,7 @@ public void testGetPublicKey() throws PushDeviceHandlerServerException, PushDevi
deviceList.add(deviceMockI);
deviceList.add(deviceMockII);
Mockito.when(deviceHandlerMock.listDevices(userID)).thenReturn(deviceList);
- Mockito.when(deviceHandlerMock.getPublicKey(userID)).thenReturn(publicKey);
+ Mockito.when(deviceHandlerMock.getPublicKey(deviceID)).thenReturn(publicKey);
// Call the method under test
String result = App2AppAuthUtils.getPublicKey(deviceID, userID, deviceHandlerMock);
// Verify the result
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthValidationTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthValidationTest.java
index 9092636d..3ebe9557 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthValidationTest.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthValidationTest.java
@@ -20,6 +20,7 @@
import com.nimbusds.jose.JOSEException;
import com.nimbusds.jwt.SignedJWT;
+import com.wso2.openbanking.accelerator.common.exception.OpenBankingException;
import com.wso2.openbanking.accelerator.common.util.JWTUtils;
import com.wso2.openbanking.accelerator.identity.app2app.cache.JTICache;
import com.wso2.openbanking.accelerator.identity.app2app.exception.JWTValidationException;
@@ -47,9 +48,9 @@
public class App2AppAuthValidationTest {
@Test(dataProviderClass = JWTDataProvider.class,
- dataProvider = "JWTProvider")
- public void validationTest(String jwtString, String publicKey) throws ParseException,
- JWTValidationException, JOSEException, NoSuchAlgorithmException, InvalidKeySpecException {
+ dataProvider = "ValidJWTProvider")
+ public void validationTest(String jwtString, String publicKey, String requestObject) throws ParseException,
+ OpenBankingException, JOSEException, NoSuchAlgorithmException, InvalidKeySpecException {
//Mocking JTICache and JWTUtils
PowerMockito.mockStatic(JTICache.class);
@@ -59,21 +60,22 @@ public void validationTest(String jwtString, String publicKey) throws ParseExcep
.thenReturn(true);
Mockito.when(JWTUtils.isValidExpiryTime(Mockito.any(Date.class), Mockito.any(long.class)))
.thenReturn(true);
- Mockito.when(JWTUtils.isvalidNotValidBeforeTime(Mockito.any(Date.class), Mockito.any(long.class)))
+ Mockito.when(JWTUtils.isValidNotValidBeforeTime(Mockito.any(Date.class), Mockito.any(long.class)))
.thenReturn(true);
//Creating a new device verification token using signed jwt
SignedJWT signedJWT = SignedJWT.parse(jwtString);
DeviceVerificationToken deviceVerificationToken = new DeviceVerificationToken(signedJWT);
deviceVerificationToken.setPublicKey(publicKey);
+ deviceVerificationToken.setRequestObject(requestObject);
// Call the method under test
App2AppAuthUtils.validateToken(deviceVerificationToken);
}
@Test(expectedExceptions = JWTValidationException.class,
dataProviderClass = JWTDataProvider.class,
- dataProvider = "JWTProvider")
- public void validationTestJTIReplayed(String jwtString, String publicKey) throws ParseException,
- JWTValidationException, JOSEException, NoSuchAlgorithmException, InvalidKeySpecException {
+ dataProvider = "ValidJWTProvider")
+ public void validationTestJTIReplayed(String jwtString, String publicKey, String requestObject) throws
+ ParseException, OpenBankingException, JOSEException, NoSuchAlgorithmException, InvalidKeySpecException {
//Mocking JTICache and JWTUtils
PowerMockito.mockStatic(JTICache.class);
@@ -83,21 +85,22 @@ public void validationTestJTIReplayed(String jwtString, String publicKey) throws
.thenReturn(true);
Mockito.when(JWTUtils.isValidExpiryTime(Mockito.any(Date.class), Mockito.any(long.class)))
.thenReturn(true);
- Mockito.when(JWTUtils.isvalidNotValidBeforeTime(Mockito.any(Date.class), Mockito.any(long.class)))
+ Mockito.when(JWTUtils.isValidNotValidBeforeTime(Mockito.any(Date.class), Mockito.any(long.class)))
.thenReturn(true);
//Creating a new device verification token using signed jwt
SignedJWT signedJWT = SignedJWT.parse(jwtString);
DeviceVerificationToken deviceVerificationToken = new DeviceVerificationToken(signedJWT);
deviceVerificationToken.setPublicKey(publicKey);
+ deviceVerificationToken.setRequestObject(requestObject);
// Call the method under test
App2AppAuthUtils.validateToken(deviceVerificationToken);
}
@Test(expectedExceptions = JWTValidationException.class,
dataProviderClass = JWTDataProvider.class,
- dataProvider = "JWTProvider")
- public void validationTestJWTExpired(String jwtString, String publicKey) throws ParseException,
- JWTValidationException, JOSEException, NoSuchAlgorithmException, InvalidKeySpecException {
+ dataProvider = "ValidJWTProvider")
+ public void validationTestJWTExpired(String jwtString, String publicKey, String requestObject) throws
+ ParseException, OpenBankingException, JOSEException, NoSuchAlgorithmException, InvalidKeySpecException {
//Mocking JTICache and JWTUtils
PowerMockito.mockStatic(JTICache.class);
@@ -107,21 +110,22 @@ public void validationTestJWTExpired(String jwtString, String publicKey) throws
.thenReturn(true);
Mockito.when(JWTUtils.isValidExpiryTime(Mockito.any(Date.class), Mockito.any(long.class)))
.thenReturn(false);
- Mockito.when(JWTUtils.isvalidNotValidBeforeTime(Mockito.any(Date.class), Mockito.any(long.class)))
+ Mockito.when(JWTUtils.isValidNotValidBeforeTime(Mockito.any(Date.class), Mockito.any(long.class)))
.thenReturn(true);
//Creating a new device verification token using signed jwt
SignedJWT signedJWT = SignedJWT.parse(jwtString);
DeviceVerificationToken deviceVerificationToken = new DeviceVerificationToken(signedJWT);
deviceVerificationToken.setPublicKey(publicKey);
+ deviceVerificationToken.setRequestObject(requestObject);
// Call the method under test
App2AppAuthUtils.validateToken(deviceVerificationToken);
}
@Test(expectedExceptions = JWTValidationException.class,
dataProviderClass = JWTDataProvider.class,
- dataProvider = "JWTProvider")
- public void validationTestJWTNotActive(String jwtString, String publicKey) throws ParseException,
- JWTValidationException, JOSEException, NoSuchAlgorithmException, InvalidKeySpecException {
+ dataProvider = "ValidJWTProvider")
+ public void validationTestJWTNotActive(String jwtString, String publicKey, String requestObject) throws
+ ParseException, OpenBankingException, JOSEException, NoSuchAlgorithmException, InvalidKeySpecException {
//Mocking JTICache and JWTUtils
PowerMockito.mockStatic(JTICache.class);
@@ -131,16 +135,41 @@ public void validationTestJWTNotActive(String jwtString, String publicKey) throw
thenReturn(true);
Mockito.when(JWTUtils.isValidExpiryTime(Mockito.any(Date.class), Mockito.any(long.class)))
.thenReturn(true);
- Mockito.when(JWTUtils.isvalidNotValidBeforeTime(Mockito.any(Date.class), Mockito.any(long.class)))
+ Mockito.when(JWTUtils.isValidNotValidBeforeTime(Mockito.any(Date.class), Mockito.any(long.class)))
.thenReturn(false);
//Creating a new device verification token using signed jwt
SignedJWT signedJWT = SignedJWT.parse(jwtString);
DeviceVerificationToken deviceVerificationToken = new DeviceVerificationToken(signedJWT);
deviceVerificationToken.setPublicKey(publicKey);
+ deviceVerificationToken.setRequestObject(requestObject);
// Call the method under test
App2AppAuthUtils.validateToken(deviceVerificationToken);
}
+ @Test(expectedExceptions = JWTValidationException.class,
+ dataProviderClass = JWTDataProvider.class,
+ dataProvider = "invalidDigestProvider")
+ public void validationTestInvalidDigest(String jwtString, String publicKey, String requestObject) throws
+ ParseException, OpenBankingException, JOSEException, NoSuchAlgorithmException, InvalidKeySpecException {
+
+ //Mocking JTICache and JWTUtils
+ PowerMockito.mockStatic(JTICache.class);
+ PowerMockito.mockStatic(JWTUtils.class);
+ Mockito.when(JTICache.getJtiDataFromCache(Mockito.anyString())).thenReturn(null);
+ Mockito.when(JWTUtils.validateJWTSignature(Mockito.any(SignedJWT.class), Mockito.anyString())).
+ thenReturn(true);
+ Mockito.when(JWTUtils.isValidExpiryTime(Mockito.any(Date.class), Mockito.any(long.class)))
+ .thenReturn(true);
+ Mockito.when(JWTUtils.isValidNotValidBeforeTime(Mockito.any(Date.class), Mockito.any(long.class)))
+ .thenReturn(true);
+ //Creating a new device verification token using signed jwt
+ SignedJWT signedJWT = SignedJWT.parse(jwtString);
+ DeviceVerificationToken deviceVerificationToken = new DeviceVerificationToken(signedJWT);
+ deviceVerificationToken.setPublicKey(publicKey);
+ deviceVerificationToken.setRequestObject(requestObject);
+ // Call the method under test
+ App2AppAuthUtils.validateToken(deviceVerificationToken);
+ }
@ObjectFactory
public IObjectFactory getObjectFactory() {
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorTest.java
index bd878760..4aaf0128 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorTest.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorTest.java
@@ -143,9 +143,6 @@ public void testProcessAuthenticationResponse_success(String jwtString) {
}
}
@Test(expectedExceptions = AuthenticationFailedException.class,
- expectedExceptionsMessageRegExp
- = ".*Failed to create Local Authenticated User from the given subject identifier. " +
- "Invalid argument. authenticatedSubjectIdentifier : .*",
dataProviderClass = App2AppAuthenticatorTestDataProvider.class,
dataProvider = "JWTProvider"
)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/testutils/App2AppAuthenticatorTestDataProvider.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/testutils/App2AppAuthenticatorTestDataProvider.java
index c9764cd2..7a9f96b6 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/testutils/App2AppAuthenticatorTestDataProvider.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/testutils/App2AppAuthenticatorTestDataProvider.java
@@ -25,13 +25,12 @@
*/
public class App2AppAuthenticatorTestDataProvider {
private static final String validAppAuthIdentifier =
- "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJkaWQiOiI1NTBmNDQ1My05NTQ3LT" +
- "RlNGYtYmUwNi04ZGIyZWVkNTYzYjMiLCJsb2dpbkhpbnQiOiJhZG1pbkB3c28yLmNvb" +
- "SIsImlhdCI6MTcxNDkyOTk2MCwianRpIjoiNmU0MWM4N2UtYWJmNi00ZjU1LTliNjQt" +
- "NjYwMWFlODg2NjZjIiwiZXhwIjoxNzE0OTMxNzYwLCJuYmYiOjE3MTQ5Mjk5NjB9.WB" +
- "7qvq3w6htUop600H5C4HwL-r0wb8GekJE6X4-zrFn2IofEcwV0yisSE5fH8uyrzdmVm" +
- "OiBgFXY9Y9cUVlS6t9HMbhlzs2qY0bVzDYVNG7GjgnYIcyh3lx9obqL9O3DJKNre5GS" +
- "3b-ATPN6VvYC9F2KnwwuoNky-3Wlcw3G9-E";
+ "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJkaWQiOiI1NTBmNDQ1My05NTQ3LTRlNGYtYmUwNi04ZGIyZWVkNTYzYjMiLCJsb" +
+ "2dpbl9oaW50IjoiYWRtaW5Ad3NvMi5jb20iLCJpYXQiOjE3MTYyNjQ5NTUsImp0aSI6IjA1NDU1Zjc1LTkwMmUtNDFhNi04ZDg4LWV" +
+ "jZTUwZDM2OTc2NSIsImRpZ2VzdCI6IlNIQS0yNTY9RWtIOGZQZ1oyVFkyWEduczhjNVZ2Y2U4aDNEQjgzVit3NDd6SGl5WWZpUT0iL" +
+ "CJleHAiOjE3MTYyNjY3NTUsIm5iZiI6MTcxNjI2NDk1NX0.C0OGMkkaosP2FSLFtqmCgRhrCG7nCJCDLsikkbFWwc5NdzxCFyYUQVI" +
+ "Zx4HIRQdabg5K8Ox-WYeqwdhajaKs5Uk63tz5UjlPzX0IKsklXgnWUxdMwfrYsu-znTce0Tc-Ph0h8a8jXF2CKTOfWxwuQvgevSqJe" +
+ "-K6zrbJmO8imu4";
@DataProvider(name = "app_auth_identifier_provider")
public Object[][] getAppAuthIdentifier() {
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/testutils/JWTDataProvider.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/testutils/JWTDataProvider.java
index 0dffaa83..f9dc6a7f 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/testutils/JWTDataProvider.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/testutils/JWTDataProvider.java
@@ -30,15 +30,53 @@ public class JWTDataProvider {
"HsR1xCsq3WH7bX1Ik/EI3weQd2zcxNbtDAUSXSy7jRBuFm1Sk52lASBbmdeOstiqlsg9ptIp/o7u1366cRjn32cXhhsR0y" +
"/spUGy8IiXz9rJfP5bEgHQIDAQ";
private final String validAppAuthIdentifier =
- "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJkaWQiOiI1NTBmNDQ1My05NTQ3LTRlNGYtYmUwNi04ZGIyZWVkNTYzY" +
- "jMiLCJsb2dpbkhpbnQiOiJhZG1pbkB3c28yLmNvbSIsImlhdCI6MTcxNTc0ODQ5MSwianRpIjoiNGIxYjUwZDQtYjRjNi0" +
- "0YTQ2LWIxNWQtMmI2ODRiNzQzOTZhIiwiZXhwIjoxNzE1NzUwMjkxLCJuYmYiOjE3MTU3NDg0OTF9.jGJcBz8eDlE2uc1u" +
- "EzhWZl72aZVkPXxeIe04OHQw0rqFz74DAATuXgKIvQXEXurz7HV19O-MHdnxZ4CI-Zz4aQQzCZ4P_MTM7pQYTPlZw2Zftq" +
- "rFEKL03TwxwKHgFuoVd2_OwTAHc5ASEhl_fSMS-IjN_8lR08XApj5CdyG8ras";
- @DataProvider(name = "JWTProvider")
- public Object[][] getJWT() {
+ "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJkaWQiOiI1NTBmNDQ1My05NTQ3LTRlNGYtYmUwNi04ZGIyZWVkNTYzYjMiLCJsb" +
+ "2dpbl9oaW50IjoiYWRtaW5Ad3NvMi5jb20iLCJpYXQiOjE3MTYyNjQ5NTUsImp0aSI6IjA1NDU1Zjc1LTkwMmUtNDFhNi04ZDg4LWV" +
+ "jZTUwZDM2OTc2NSIsImRpZ2VzdCI6IlNIQS0yNTY9RWtIOGZQZ1oyVFkyWEduczhjNVZ2Y2U4aDNEQjgzVit3NDd6SGl5WWZpUT0iL" +
+ "CJleHAiOjE3MTYyNjY3NTUsIm5iZiI6MTcxNjI2NDk1NX0.C0OGMkkaosP2FSLFtqmCgRhrCG7nCJCDLsikkbFWwc5NdzxCFyYUQVI" +
+ "Zx4HIRQdabg5K8Ox-WYeqwdhajaKs5Uk63tz5UjlPzX0IKsklXgnWUxdMwfrYsu-znTce0Tc-Ph0h8a8jXF2CKTOfWxwuQvgevSqJe" +
+ "-K6zrbJmO8imu4";
+ private final String appAuthIdentifierMissingDigest =
+ "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJkaWQiOiI1NTBmNDQ1My05NTQ3LTRlNGYtYmUwNi04ZGIyZWVkNTYzYjMiLCJsb" +
+ "2dpbl9oaW50IjoiYWRtaW5Ad3NvMi5jb20iLCJpYXQiOjE3MTYyNjcyMDMsImp0aSI6ImZkNDhmOWMzLTYyZDMtNDUzZS04MWY2LTF" +
+ "kMGE4ZDIzM2YzZiIsImV4cCI6MTcxNjI2OTAwMywibmJmIjoxNzE2MjY3MjAzfQ.C_G5-_McCMTz6D01XpPVfrdGlPLaKli9cqWL5K" +
+ "nd5ntlDq5ww7J769EJdCGt-S5sfgg5hrPRhyIWK2MJwavGTMzsp1vGdUQXQkT7z68_20k82Lms67tQLIM1VUCDc9rqz5Pule5bVqbY" +
+ "oZFmFlHU0Hcmvy166J6c9HlySyMC994";
+ private final String appAuthIdentifierInvalidDigest =
+ "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJkaWQiOiI1NTBmNDQ1My05NTQ3LTRlNGYtYmUwNi04ZGIyZWVkNTYzYjMiLCJsb" +
+ "2dpbl9oaW50IjoiYWRtaW5Ad3NvMi5jb20iLCJpYXQiOjE3MTYyNjc0MjYsImp0aSI6IjYyM2ZhZDY3LTc0ZDMtNDk4OS04YTc1LTE" +
+ "2OWYxNDQzOGUwZiIsImRpZ2VzdCI6IlNIQS0yNTY9WUJlc3lUWnhIMWtBVitMTTNKMzZDdzQrVXlQYWlKS0VydVhsdGxsbS9DRT0iL" +
+ "CJleHAiOjE3MTYyNjkyMjYsIm5iZiI6MTcxNjI2NzQyNn0.hsuj0osE-o_hyOif7eUvVFIfJpmzF2bDqeINj2Qq2XMQ1Lbnf7LgYMG" +
+ "POzmtMi1Jp9Ivwl_3Wt35PcCVko2LI2TIoG-JB8MMeWc1okwwdWGP8Rz5TWCnaXiPGeeFw4PjuV3JMbWeTFafqUFtJUX7pU-8q_hiQ" +
+ "zxK1mGjRTjDXRA";
+ private final String validRequestObject =
+ "eyJraWQiOiI3ZUo4U19aZ3ZsWXhGQUZTZ2hWOXhNSlJPdmsiLCJhbGciOiJQUzI1NiIsInR5cCI6IkpXVCJ9.eyJtYXhfYWdlIjo4N" +
+ "jQwMCwiYXVkIjoiaHR0cHM6Ly8xOTIuMTY4LjQzLjQ5Ojk0NDYvb2F1dGgyL3Rva2VuIiwic2NvcGUiOiJhY2NvdW50cyBvcGVuaWQ" +
+ "iLCJpc3MiOiI2RWZaSTVOUnByTm9tZlFQWElQZjFSN0ZsNUVhIiwiY2xhaW1zIjp7ImlkX3Rva2VuIjp7ImFjciI6eyJ2YWx1ZXMiO" +
+ "lsidXJuOm9wZW5iYW5raW5nOnBzZDI6c2NhIiwidXJuOm9wZW5iYW5raW5nOnBzZDI6Y2EiXSwiZXNzZW50aWFsIjp0cnVlfSwib3B" +
+ "lbmJhbmtpbmdfaW50ZW50X2lkIjp7InZhbHVlIjoiZTkyNmE2MzItYzlkMy00MmEwLWEyM2YtMWEwMWZhNDAwOWU3IiwiZXNzZW50a" +
+ "WFsIjp0cnVlfX0sInVzZXJpbmZvIjp7Im9wZW5iYW5raW5nX2ludGVudF9pZCI6eyJ2YWx1ZSI6ImU5MjZhNjMyLWM5ZDMtNDJhMC1" +
+ "hMjNmLTFhMDFmYTQwMDllNyIsImVzc2VudGlhbCI6dHJ1ZX19fSwicmVzcG9uc2VfdHlwZSI6ImNvZGUgaWRfdG9rZW4iLCJyZWRpc" +
+ "mVjdF91cmkiOiJodHRwczovL3d3dy5tb2NrY29tcGFueS5jb20vcmVkaXJlY3RzL3JlZGlyZWN0MSIsInN0YXRlIjoiWVdsemNEb3p" +
+ "NVFE0IiwiZXhwIjoxODA3MjMzNDc4LCJub25jZSI6Im4tMFM2X1d6QTJNbCIsImNsaWVudF9pZCI6IjZFZlpJNU5ScHJOb21mUVBYS" +
+ "VBmMVI3Rmw1RWEifQ.nKapNc1N5AHxil-xbVpSXrDRsGYkn1YHe1jURxZMVRluDWnyRmjVce9AJ5lCl338Jg0EsU4CNmLwOSu7zmtl" +
+ "DCFz4fCIHLj1Q8A-C5I9cWE-nAlV1HnCR_3V7cTU4YE13ZIH7bMCqOPfBX_fpDkJeDXoSnRHQtipMPqIwNfmv7Kf4SjPpZ7kT5zmDn" +
+ "cHsUqotpPVoPka_-Nal0KL_-PknC31pKECcxakOFNTeAeiODZN5JIyKGFtq10jQaJi7YvDKsGg1l3rv1gUdJ4s5eXqmnxJUu4J6ocY" +
+ "h26Nz3l_Xc1p7XIm2HPhvSW3DpbNpE8Ej0kJkI9FgWz77QACkiO4Hg";
+
+ @DataProvider(name = "ValidJWTProvider")
+ public Object[][] getDigest() {
+ return new String[][]{
+ {validAppAuthIdentifier, validPublicKey, null},
+ {validAppAuthIdentifier, validPublicKey, validRequestObject}
+ };
+ }
+
+ @DataProvider(name = "invalidDigestProvider")
+ public Object[][] getInvalidDigest() {
return new String[][]{
- {validAppAuthIdentifier, validPublicKey},
+ {appAuthIdentifierMissingDigest, validPublicKey, validRequestObject},
+ {appAuthIdentifierInvalidDigest, validPublicKey, validRequestObject}
};
}
}
From cbf2bbd7f62fb95d3d0e721f80e52b914d8fe80d Mon Sep 17 00:00:00 2001
From: ImalshaD
Date: Tue, 21 May 2024 14:49:30 +0530
Subject: [PATCH 188/281] Comments resolved.
---
.../accelerator/common/util/JWTUtils.java | 5 +-
.../app2app/App2AppAuthenticator.java | 78 +++++++++++++------
.../App2AppAuthenticatorConstants.java | 15 ++--
.../app2app/validations/DigestValidator.java | 1 +
.../app2app/App2AppAuthValidationTest.java | 12 +--
.../app2app/App2AppAuthenticatorTest.java | 14 ++--
.../App2AppAuthenticatorTestDataProvider.java | 2 +-
...a => App2AppUtilsTestJWTDataProvider.java} | 2 +-
8 files changed, 82 insertions(+), 47 deletions(-)
rename open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/testutils/{JWTDataProvider.java => App2AppUtilsTestJWTDataProvider.java} (99%)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/JWTUtils.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/JWTUtils.java
index 02781907..dde44b0f 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/JWTUtils.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/JWTUtils.java
@@ -153,12 +153,15 @@ public static boolean validateJWTSignature(SignedJWT signedJWT, String publicKey
byte[] publicKeyData = Base64.getDecoder().decode(publicKey);
X509EncodedKeySpec spec = new X509EncodedKeySpec(publicKeyData);
+ // Example : RS256
String algorithm = signedJWT.getHeader().getAlgorithm().getName();
KeyFactory kf;
+ // In here if the algorithm is directly passes (like RS256) it will generate exceptions
+ // hence RSA should be passed
if (algorithm.indexOf(RS) == 0) {
kf = KeyFactory.getInstance(ALGORITHM_RSA);
} else {
- throw new OpenBankingException("Algorithm " + algorithm + "not yet supported.");
+ throw new OpenBankingException("Algorithm " + algorithm + " not yet supported.");
}
RSAPublicKey rsapublicKey = (RSAPublicKey) kf.generatePublic(spec);
JWSVerifier verifier = new RSASSAVerifier(rsapublicKey);
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticator.java
index 1b79fa52..beb348c7 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticator.java
@@ -55,7 +55,19 @@ public class App2AppAuthenticator extends AbstractApplicationAuthenticator
private static DeviceHandler deviceHandler;
/**
- * {@inheritDoc}
+ * Constructor for the App2AppAuthenticator.
+ */
+ public App2AppAuthenticator() {
+
+ if (deviceHandler == null) {
+ deviceHandler = new DeviceHandlerImpl();
+ }
+ }
+
+ /**
+ * This method is used to get authenticator name.
+ *
+ * @return String Authenticator name.
*/
@Override
public String getName() {
@@ -64,7 +76,9 @@ public String getName() {
}
/**
- * {@inheritDoc}
+ * This method is used to get the friendly name of the authenticator.
+ *
+ * @return String Friendly name of the authenticator
*/
@Override
public String getFriendlyName() {
@@ -73,7 +87,16 @@ public String getFriendlyName() {
}
/**
- * {@inheritDoc}
+ * This method processes the authentication response received from the client.
+ * It verifies the authenticity of the received JWT token, extracts necessary information,
+ * and performs validations before authenticating the user.
+ *
+ * @param httpServletRequest The HTTP servlet request object containing the authentication response.
+ * @param httpServletResponse The HTTP servlet response object for sending responses.
+ * @param authenticationContext The authentication context containing information related to the authentication
+ * process.
+ * @throws AuthenticationFailedException If authentication fails due to various reasons such as missing parameters,
+ * parsing errors, JWT validation errors, or exceptions during authentication process.
*/
@Override
protected void processAuthenticationResponse(HttpServletRequest httpServletRequest,
@@ -97,9 +120,9 @@ protected void processAuthenticationResponse(HttpServletRequest httpServletReque
//Checking whether deviceId and loginHint present in passed jwt
if (StringUtils.isBlank(loginHint) || StringUtils.isBlank(deviceID)) {
if (log.isDebugEnabled()) {
- log.debug(App2AppAuthenticatorConstants.REQUIRED_PRAMAS_MISSING_MESSAGE);
+ log.debug(App2AppAuthenticatorConstants.REQUIRED_PARAMS_MISSING_MESSAGE);
}
- throw new AuthenticationFailedException(App2AppAuthenticatorConstants.REQUIRED_PRAMAS_MISSING_MESSAGE);
+ throw new AuthenticationFailedException(App2AppAuthenticatorConstants.REQUIRED_PARAMS_MISSING_MESSAGE);
}
AuthenticatedUser userToBeAuthenticated =
@@ -121,27 +144,40 @@ protected void processAuthenticationResponse(HttpServletRequest httpServletReque
userToBeAuthenticated.getUserName()));
}
} catch (ParseException e) {
+ log.error(e.getMessage());
throw new AuthenticationFailedException(App2AppAuthenticatorConstants.PARSE_EXCEPTION_MESSAGE, e);
} catch (JWTValidationException e) {
- throw new AuthenticationFailedException(App2AppAuthenticatorConstants.JWT_VALIDATION_EXCEPTION_MESSAGE, e);
+ log.error(e.getMessage());
+ throw new AuthenticationFailedException
+ (App2AppAuthenticatorConstants.APP_AUTH_IDENTIFIER_VALIDATION_EXCEPTION_MESSAGE, e);
} catch (OpenBankingException e) {
+ log.error(e.getMessage());
throw new AuthenticationFailedException(App2AppAuthenticatorConstants.OPEN_BANKING_EXCEPTION_MESSAGE, e);
} catch (PushDeviceHandlerServerException e) {
+ log.error(e.getMessage());
throw new AuthenticationFailedException
(App2AppAuthenticatorConstants.PUSH_DEVICE_HANDLER_SERVER_EXCEPTION_MESSAGE, e);
} catch (UserStoreException e) {
+ log.error(e.getMessage());
throw new AuthenticationFailedException(App2AppAuthenticatorConstants.USER_STORE_EXCEPTION_MESSAGE, e);
} catch (PushDeviceHandlerClientException e) {
+ log.error(e.getMessage());
throw new AuthenticationFailedException
(App2AppAuthenticatorConstants.PUSH_DEVICE_HANDLER_CLIENT_EXCEPTION_MESSAGE, e);
} catch (IllegalArgumentException e) {
+ log.error(e.getMessage());
throw new
AuthenticationFailedException(App2AppAuthenticatorConstants.ILLEGAL_ARGUMENT_EXCEPTION_MESSAGE, e);
}
}
/**
- * {@inheritDoc}
+ * Determines whether this authenticator can handle the incoming HTTP servlet request.
+ * This method checks if the request contains the necessary parameter for App2App authentication,
+ * which is the device verification token identifier.
+ *
+ * @param httpServletRequest The HTTP servlet request object to be checked for handling.
+ * @return True if this authenticator can handle the request, false otherwise.
*/
@Override
public boolean canHandle(HttpServletRequest httpServletRequest) {
@@ -155,7 +191,10 @@ public boolean canHandle(HttpServletRequest httpServletRequest) {
}
/**
- * {@inheritDoc}
+ * Retrieves the context identifier(sessionDataKey in this case) from the HTTP servlet request.
+ *
+ * @param request The HTTP servlet request object from which to retrieve the context identifier.
+ * @return The context identifier extracted from the request, typically representing session data key.
*/
@Override
public String getContextIdentifier(HttpServletRequest request) {
@@ -164,7 +203,13 @@ public String getContextIdentifier(HttpServletRequest request) {
}
/**
- * {@inheritDoc}
+ * Initiates the authentication request, but App2App authenticator does not support this operation.
+ * Therefore, this method terminates the authentication process and throws an AuthenticationFailedException.
+ *
+ * @param request The HTTP servlet request object.
+ * @param response The HTTP servlet response object.
+ * @param context The authentication context.
+ * @throws AuthenticationFailedException if this method is called
*/
@Override
protected void initiateAuthenticationRequest(HttpServletRequest request,
@@ -195,24 +240,9 @@ private String getPublicKeyByDeviceID(String deviceID, AuthenticatedUser authent
throws UserStoreException, PushDeviceHandlerServerException, PushDeviceHandlerClientException,
OpenBankingException {
- DeviceHandler deviceHandler = getDeviceHandler();
UserRealm userRealm = App2AppAuthUtils.getUserRealm(authenticatedUser);
String userID = App2AppAuthUtils.getUserIdFromUsername(authenticatedUser.getUserName(), userRealm);
return App2AppAuthUtils.getPublicKey(deviceID, userID, deviceHandler);
}
-
- /**
- * Method to get a DeviceHandler implementation.
- *
- * @return an implementation of DeviceHandler
- */
- private DeviceHandler getDeviceHandler() {
-
- if (deviceHandler == null) {
- deviceHandler = new DeviceHandlerImpl();
- }
-
- return deviceHandler;
- }
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorConstants.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorConstants.java
index ab9b6175..4dbd95c8 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorConstants.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorConstants.java
@@ -28,23 +28,24 @@ public class App2AppAuthenticatorConstants {
public static final String REQUEST = "request";
public static final String DEVICE_VERIFICATION_TOKEN_IDENTIFIER = "deviceVerificationToken";
public static final String SESSION_DATA_KEY = "sessionDataKey";
- public static final String JWT_VALIDATION_EXCEPTION_MESSAGE = "Error while validating JWT: ";
+ public static final String APP_AUTH_IDENTIFIER_VALIDATION_EXCEPTION_MESSAGE
+ = "Error while validating App Auth Identifier.";
public static final String ILLEGAL_ARGUMENT_EXCEPTION_MESSAGE
- = "Error while creating user for provided loginHint: ";
- public static final String PARSE_EXCEPTION_MESSAGE = "Error while parsing the provided JWT: ";
+ = "Error while creating user for provided loginHint.";
+ public static final String PARSE_EXCEPTION_MESSAGE = "Error while parsing the provided JWT.";
public static final String PUSH_DEVICE_HANDLER_SERVER_EXCEPTION_MESSAGE
= "Error occurred in push device handler service: ";
- public static final String USER_STORE_EXCEPTION_MESSAGE = "Error while creating authenticated user: ";
+ public static final String USER_STORE_EXCEPTION_MESSAGE = "Error while creating authenticated user.";
public static final String PUSH_DEVICE_HANDLER_CLIENT_EXCEPTION_MESSAGE
- = "Error occurred in Push Device handler client: ";
+ = "Error occurred in Push Device handler client.";
public static final String INITIALIZATION_ERROR_MESSAGE = "Initializing App2App authenticator is not supported.";
public static final String DEVICE_VERIFICATION_TOKEN_MISSING_ERROR_MESSAGE
= "Device verification token null or empty in request.";
public static final String USER_AUTHENTICATED_MSG
= "User {%s} authenticated by app2app authenticator successfully.";
public static final String OPEN_BANKING_EXCEPTION_MESSAGE
- = "Error while retrieving user: ";
- public static final String REQUIRED_PRAMAS_MISSING_MESSAGE
+ = "Error while retrieving user.";
+ public static final String REQUIRED_PARAMS_MISSING_MESSAGE
= "Required Parameters did or loginHint null or empty.";
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/DigestValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/DigestValidator.java
index 8ebe08b4..68ea1681 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/DigestValidator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/DigestValidator.java
@@ -97,3 +97,4 @@ protected boolean validateDigest(String digestHeader, String request) {
return false;
}
}
+
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthValidationTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthValidationTest.java
index 3ebe9557..8da8ef22 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthValidationTest.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthValidationTest.java
@@ -25,7 +25,7 @@
import com.wso2.openbanking.accelerator.identity.app2app.cache.JTICache;
import com.wso2.openbanking.accelerator.identity.app2app.exception.JWTValidationException;
import com.wso2.openbanking.accelerator.identity.app2app.model.DeviceVerificationToken;
-import com.wso2.openbanking.accelerator.identity.app2app.testutils.JWTDataProvider;
+import com.wso2.openbanking.accelerator.identity.app2app.testutils.App2AppUtilsTestJWTDataProvider;
import com.wso2.openbanking.accelerator.identity.app2app.utils.App2AppAuthUtils;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
@@ -47,7 +47,7 @@
@PowerMockIgnore({"javax.net.ssl.*", "jdk.internal.reflect.*"})
public class App2AppAuthValidationTest {
- @Test(dataProviderClass = JWTDataProvider.class,
+ @Test(dataProviderClass = App2AppUtilsTestJWTDataProvider.class,
dataProvider = "ValidJWTProvider")
public void validationTest(String jwtString, String publicKey, String requestObject) throws ParseException,
OpenBankingException, JOSEException, NoSuchAlgorithmException, InvalidKeySpecException {
@@ -72,7 +72,7 @@ public void validationTest(String jwtString, String publicKey, String requestObj
}
@Test(expectedExceptions = JWTValidationException.class,
- dataProviderClass = JWTDataProvider.class,
+ dataProviderClass = App2AppUtilsTestJWTDataProvider.class,
dataProvider = "ValidJWTProvider")
public void validationTestJTIReplayed(String jwtString, String publicKey, String requestObject) throws
ParseException, OpenBankingException, JOSEException, NoSuchAlgorithmException, InvalidKeySpecException {
@@ -97,7 +97,7 @@ public void validationTestJTIReplayed(String jwtString, String publicKey, String
}
@Test(expectedExceptions = JWTValidationException.class,
- dataProviderClass = JWTDataProvider.class,
+ dataProviderClass = App2AppUtilsTestJWTDataProvider.class,
dataProvider = "ValidJWTProvider")
public void validationTestJWTExpired(String jwtString, String publicKey, String requestObject) throws
ParseException, OpenBankingException, JOSEException, NoSuchAlgorithmException, InvalidKeySpecException {
@@ -122,7 +122,7 @@ public void validationTestJWTExpired(String jwtString, String publicKey, String
}
@Test(expectedExceptions = JWTValidationException.class,
- dataProviderClass = JWTDataProvider.class,
+ dataProviderClass = App2AppUtilsTestJWTDataProvider.class,
dataProvider = "ValidJWTProvider")
public void validationTestJWTNotActive(String jwtString, String publicKey, String requestObject) throws
ParseException, OpenBankingException, JOSEException, NoSuchAlgorithmException, InvalidKeySpecException {
@@ -147,7 +147,7 @@ public void validationTestJWTNotActive(String jwtString, String publicKey, Strin
}
@Test(expectedExceptions = JWTValidationException.class,
- dataProviderClass = JWTDataProvider.class,
+ dataProviderClass = App2AppUtilsTestJWTDataProvider.class,
dataProvider = "invalidDigestProvider")
public void validationTestInvalidDigest(String jwtString, String publicKey, String requestObject) throws
ParseException, OpenBankingException, JOSEException, NoSuchAlgorithmException, InvalidKeySpecException {
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorTest.java
index 4aaf0128..812b4e08 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorTest.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorTest.java
@@ -120,7 +120,7 @@ public void getContextIdentifierTest(String sessionDataKey) {
}
@Test(dataProviderClass = App2AppAuthenticatorTestDataProvider.class,
- dataProvider = "JWTProvider")
+ dataProvider = "AppAuthIdentifierProvider")
public void testProcessAuthenticationResponse_success(String jwtString) {
PowerMockito.mockStatic(App2AppAuthUtils.class);
@@ -144,7 +144,7 @@ public void testProcessAuthenticationResponse_success(String jwtString) {
}
@Test(expectedExceptions = AuthenticationFailedException.class,
dataProviderClass = App2AppAuthenticatorTestDataProvider.class,
- dataProvider = "JWTProvider"
+ dataProvider = "AppAuthIdentifierProvider"
)
public void testProcessAuthenticationResponse_IllegalArgumentException(String jwtString)
throws AuthenticationFailedException {
@@ -163,7 +163,7 @@ public void testProcessAuthenticationResponse_IllegalArgumentException(String jw
@Test(expectedExceptions = AuthenticationFailedException.class,
dataProviderClass = App2AppAuthenticatorTestDataProvider.class,
- dataProvider = "JWTProvider"
+ dataProvider = "AppAuthIdentifierProvider"
)
public void testProcessAuthenticationResponse_ParseException(String jwtString)
throws AuthenticationFailedException, ParseException {
@@ -181,7 +181,7 @@ public void testProcessAuthenticationResponse_ParseException(String jwtString)
@Test(expectedExceptions = AuthenticationFailedException.class,
dataProviderClass = App2AppAuthenticatorTestDataProvider.class,
- dataProvider = "JWTProvider"
+ dataProvider = "AppAuthIdentifierProvider"
)
public void testProcessAuthenticationResponse_UserStoreException(String jwtString)
throws AuthenticationFailedException, UserStoreException {
@@ -203,7 +203,7 @@ public void testProcessAuthenticationResponse_UserStoreException(String jwtStrin
@Test(expectedExceptions = AuthenticationFailedException.class,
dataProviderClass = App2AppAuthenticatorTestDataProvider.class,
- dataProvider = "JWTProvider"
+ dataProvider = "AppAuthIdentifierProvider"
)
public void testProcessAuthenticationResponse_PushDeviceHandlerServerException(String jwtString)
throws AuthenticationFailedException, OpenBankingException, PushDeviceHandlerServerException,
@@ -227,7 +227,7 @@ public void testProcessAuthenticationResponse_PushDeviceHandlerServerException(S
@Test(expectedExceptions = AuthenticationFailedException.class,
dataProviderClass = App2AppAuthenticatorTestDataProvider.class,
- dataProvider = "JWTProvider"
+ dataProvider = "AppAuthIdentifierProvider"
)
public void testProcessAuthenticationResponse_PushDeviceHandlerClientException(String jwtString)
throws AuthenticationFailedException, OpenBankingException, PushDeviceHandlerServerException,
@@ -251,7 +251,7 @@ public void testProcessAuthenticationResponse_PushDeviceHandlerClientException(S
@Test(expectedExceptions = AuthenticationFailedException.class,
dataProviderClass = App2AppAuthenticatorTestDataProvider.class,
- dataProvider = "JWTProvider"
+ dataProvider = "AppAuthIdentifierProvider"
)
public void testProcessAuthenticationResponse_OpenBankingException(String jwtString)
throws AuthenticationFailedException, OpenBankingException, PushDeviceHandlerServerException,
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/testutils/App2AppAuthenticatorTestDataProvider.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/testutils/App2AppAuthenticatorTestDataProvider.java
index 7a9f96b6..ac39da2e 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/testutils/App2AppAuthenticatorTestDataProvider.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/testutils/App2AppAuthenticatorTestDataProvider.java
@@ -52,7 +52,7 @@ public Object[][] getSessionDataKey() {
};
}
- @DataProvider(name = "JWTProvider")
+ @DataProvider(name = "AppAuthIdentifierProvider")
public Object[][] getJWT() {
return new String[][]{
{validAppAuthIdentifier},
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/testutils/JWTDataProvider.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/testutils/App2AppUtilsTestJWTDataProvider.java
similarity index 99%
rename from open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/testutils/JWTDataProvider.java
rename to open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/testutils/App2AppUtilsTestJWTDataProvider.java
index f9dc6a7f..ffbc0f39 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/testutils/JWTDataProvider.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/testutils/App2AppUtilsTestJWTDataProvider.java
@@ -23,7 +23,7 @@
/**
* JWT Data provider for App2AppAuthValidation Testing.
*/
-public class JWTDataProvider {
+public class App2AppUtilsTestJWTDataProvider {
private final String validPublicKey =
"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDLyl7YvRhy57IbxuhV4n7OZw0mmnnXNsDJmL4YQNXy2bRCs59pJb+TYO" +
From 83e631f5cf7f0e52f6460082da104e93ca98e07e Mon Sep 17 00:00:00 2001
From: ImalshaD
Date: Wed, 22 May 2024 08:30:40 +0530
Subject: [PATCH 189/281] Comments resolved.
---
.../accelerator/common/util/JWTUtils.java | 35 +++++++++++++------
.../gateway/executor/dcr/DCRExecutor.java | 2 +-
.../app2app/validations/DigestValidator.java | 15 +++++---
.../PublicKeySignatureValidator.java | 2 +-
.../dcr/validation/SignatureValidator.java | 3 +-
.../app2app/App2AppAuthValidationTest.java | 10 +++---
6 files changed, 43 insertions(+), 24 deletions(-)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/JWTUtils.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/JWTUtils.java
index dde44b0f..038b8124 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/JWTUtils.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/JWTUtils.java
@@ -101,7 +101,7 @@ public static JSONObject decodeRequestJWT(String jwtToken, String jwtPart) throw
* @throws MalformedURLException if an error occurs while creating the URL object
*/
@Generated(message = "Excluding from code coverage since can not call this method due to external https call")
- public static boolean validateJWTSignature(String jwtString, String jwksUri, String algorithm)
+ public static boolean isValidSignature(String jwtString, String jwksUri, String algorithm)
throws ParseException, BadJOSEException, JOSEException, MalformedURLException {
int defaultConnectionTimeout = 3000;
@@ -147,22 +147,15 @@ public static boolean validateJWTSignature(String jwtString, String jwksUri, Str
* @throws InvalidKeySpecException if the provided key is invalid
* @throws JOSEException if an error occurs during the signature validation process
*/
- @Generated(message = "Excluding from code coverage as KeyFactory does not initialize")
- public static boolean validateJWTSignature(SignedJWT signedJWT, String publicKey)
+ @Generated(message = "Excluding from code coverage as KeyFactory does not initialize in testsuite")
+ public static boolean isValidSignature(SignedJWT signedJWT, String publicKey)
throws NoSuchAlgorithmException, InvalidKeySpecException, JOSEException, OpenBankingException {
byte[] publicKeyData = Base64.getDecoder().decode(publicKey);
X509EncodedKeySpec spec = new X509EncodedKeySpec(publicKeyData);
// Example : RS256
String algorithm = signedJWT.getHeader().getAlgorithm().getName();
- KeyFactory kf;
- // In here if the algorithm is directly passes (like RS256) it will generate exceptions
- // hence RSA should be passed
- if (algorithm.indexOf(RS) == 0) {
- kf = KeyFactory.getInstance(ALGORITHM_RSA);
- } else {
- throw new OpenBankingException("Algorithm " + algorithm + " not yet supported.");
- }
+ KeyFactory kf = getKeyFactory(algorithm);
RSAPublicKey rsapublicKey = (RSAPublicKey) kf.generatePublic(spec);
JWSVerifier verifier = new RSASSAVerifier(rsapublicKey);
return signedJWT.verify(verifier);
@@ -237,5 +230,25 @@ public static boolean isValidNotValidBeforeTime(Date notBeforeTime, long default
return false;
}
}
+
+ /**
+ * Returns a KeyFactory instance for the specified algorithm.
+ *
+ * @param algorithm the algorithm name, such as "RS256".
+ * @return the KeyFactory instance.
+ * @throws OpenBankingException if the provided algorithm is not supported.
+ * @throws NoSuchAlgorithmException if the specified algorithm is invalid.
+ */
+ @Generated(message = "Excluding from code coverage as KeyFactory does not initialize in testsuite")
+ private static KeyFactory getKeyFactory(String algorithm) throws OpenBankingException, NoSuchAlgorithmException {
+
+ // In here if the algorithm is directly passes (like RS256) it will generate exceptions
+ // hence Base algorithm should be passed (Example: RSA)
+ if (algorithm.indexOf(RS) == 0) {
+ return KeyFactory.getInstance(ALGORITHM_RSA);
+ } else {
+ throw new OpenBankingException("Algorithm " + algorithm + " not yet supported.");
+ }
+ }
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/dcr/DCRExecutor.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/dcr/DCRExecutor.java
index f4c2e114..ae4670e2 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/dcr/DCRExecutor.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/src/main/java/com/wso2/openbanking/accelerator/gateway/executor/dcr/DCRExecutor.java
@@ -835,7 +835,7 @@ private void validateRequestSignature(String payload, OBAPIRequestContext obapiR
String jwksEndpoint = decodedSSA.getAsString(jwksEndpointName);
SignedJWT signedJWT = SignedJWT.parse(payload);
String alg = signedJWT.getHeader().getAlgorithm().getName();
- JWTUtils.validateJWTSignature(payload, jwksEndpoint, alg);
+ JWTUtils.isValidSignature(payload, jwksEndpoint, alg);
obapiRequestContext.setModifiedPayload(decodedRequest.toJSONString());
Map requestHeaders = obapiRequestContext.getMsgInfo().getHeaders();
requestHeaders.remove("Content-Type");
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/DigestValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/DigestValidator.java
index 68ea1681..865d1fdd 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/DigestValidator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/DigestValidator.java
@@ -34,6 +34,7 @@
/**
* Validator class for validating digest of a device verification token.
+ * Digest here is expected to be the hash of the request object if it is present.
*/
public class DigestValidator implements ConstraintValidator {
@@ -52,19 +53,20 @@ public boolean isValid(DeviceVerificationToken deviceVerificationToken,
String requestObject = deviceVerificationToken.getRequestObject();
String digest = deviceVerificationToken.getDigest();
- return validateDigest(digest, requestObject);
+ return isDigestValid(digest, requestObject);
}
/**
* Validating the digest of the request.
+ * DigestHeader is expected to be the hash of requestObject if request Object is not null.
*
* @param digestHeader digest header sent with the request
- * @param request the request JWT String
+ * @param requestObject the request JWT String
* @return return true if the digest validation is a success, false otherwise
*/
- protected boolean validateDigest(String digestHeader, String request) {
+ protected boolean isDigestValid(String digestHeader, String requestObject) {
- if (StringUtils.isBlank(request)) {
+ if (StringUtils.isBlank(requestObject)) {
//If the request is null nothing to validate.
return true;
} else if (StringUtils.isBlank(digestHeader)) {
@@ -73,15 +75,18 @@ protected boolean validateDigest(String digestHeader, String request) {
}
try {
+ // Example : SHA-256=EkH8fPgZ2TY2XGns8c5Vvce8h3DB83V+w47zHiyYfiQ=
String[] digestAttribute = digestHeader.split("=", 2);
+
if (digestAttribute.length != 2) {
log.error("Invalid digest header.");
return false;
}
+ // Example : SHA-256
String digestAlgorithm = digestAttribute[0].trim();
String digestValue = digestAttribute[1].trim();
MessageDigest messageDigest = MessageDigest.getInstance(digestAlgorithm);
- byte[] digestHash = messageDigest.digest(request.getBytes(StandardCharsets.UTF_8));
+ byte[] digestHash = messageDigest.digest(requestObject.getBytes(StandardCharsets.UTF_8));
String generatedDigest = Base64.getEncoder()
.encodeToString(digestHash);
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/PublicKeySignatureValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/PublicKeySignatureValidator.java
index d8bb1287..6ea59823 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/PublicKeySignatureValidator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/PublicKeySignatureValidator.java
@@ -55,7 +55,7 @@ public boolean isValid(DeviceVerificationToken deviceVerificationToken,
String publicKey = deviceVerificationToken.getPublicKey();
try {
- if (!JWTUtils.validateJWTSignature(signedJWT, publicKey)) {
+ if (!JWTUtils.isValidSignature(signedJWT, publicKey)) {
log.error("Signature can't be verified with registered public key.");
return false;
}
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/validation/SignatureValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/validation/SignatureValidator.java
index 29091566..a991256f 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/validation/SignatureValidator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/dcr/validation/SignatureValidator.java
@@ -95,7 +95,7 @@ public boolean isValid(Object registrationRequest,
private boolean isValidateJWTSignature(String jwksURL, String jwtString, String alg) {
try {
- return JWTUtils.validateJWTSignature(jwtString, jwksURL, alg);
+ return JWTUtils.isValidSignature(jwtString, jwksURL, alg);
} catch (ParseException e) {
log.error("Error while parsing the JWT string", e);
} catch (JOSEException | BadJOSEException | MalformedURLException e) {
@@ -104,3 +104,4 @@ private boolean isValidateJWTSignature(String jwksURL, String jwtString, String
return false;
}
}
+
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthValidationTest.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthValidationTest.java
index 8da8ef22..36e24abd 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthValidationTest.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/test/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthValidationTest.java
@@ -56,7 +56,7 @@ public void validationTest(String jwtString, String publicKey, String requestObj
PowerMockito.mockStatic(JTICache.class);
PowerMockito.mockStatic(JWTUtils.class);
Mockito.when(JTICache.getJtiDataFromCache(Mockito.anyString())).thenReturn(null);
- Mockito.when(JWTUtils.validateJWTSignature(Mockito.any(SignedJWT.class), Mockito.anyString()))
+ Mockito.when(JWTUtils.isValidSignature(Mockito.any(SignedJWT.class), Mockito.anyString()))
.thenReturn(true);
Mockito.when(JWTUtils.isValidExpiryTime(Mockito.any(Date.class), Mockito.any(long.class)))
.thenReturn(true);
@@ -81,7 +81,7 @@ public void validationTestJTIReplayed(String jwtString, String publicKey, String
PowerMockito.mockStatic(JTICache.class);
PowerMockito.mockStatic(JWTUtils.class);
Mockito.when(JTICache.getJtiDataFromCache(Mockito.anyString())).thenReturn("NotNullJTI");
- Mockito.when(JWTUtils.validateJWTSignature(Mockito.any(SignedJWT.class), Mockito.anyString()))
+ Mockito.when(JWTUtils.isValidSignature(Mockito.any(SignedJWT.class), Mockito.anyString()))
.thenReturn(true);
Mockito.when(JWTUtils.isValidExpiryTime(Mockito.any(Date.class), Mockito.any(long.class)))
.thenReturn(true);
@@ -106,7 +106,7 @@ public void validationTestJWTExpired(String jwtString, String publicKey, String
PowerMockito.mockStatic(JTICache.class);
PowerMockito.mockStatic(JWTUtils.class);
Mockito.when(JTICache.getJtiDataFromCache(Mockito.anyString())).thenReturn(null);
- Mockito.when(JWTUtils.validateJWTSignature(Mockito.any(SignedJWT.class), Mockito.anyString()))
+ Mockito.when(JWTUtils.isValidSignature(Mockito.any(SignedJWT.class), Mockito.anyString()))
.thenReturn(true);
Mockito.when(JWTUtils.isValidExpiryTime(Mockito.any(Date.class), Mockito.any(long.class)))
.thenReturn(false);
@@ -131,7 +131,7 @@ public void validationTestJWTNotActive(String jwtString, String publicKey, Strin
PowerMockito.mockStatic(JTICache.class);
PowerMockito.mockStatic(JWTUtils.class);
Mockito.when(JTICache.getJtiDataFromCache(Mockito.anyString())).thenReturn(null);
- Mockito.when(JWTUtils.validateJWTSignature(Mockito.any(SignedJWT.class), Mockito.anyString())).
+ Mockito.when(JWTUtils.isValidSignature(Mockito.any(SignedJWT.class), Mockito.anyString())).
thenReturn(true);
Mockito.when(JWTUtils.isValidExpiryTime(Mockito.any(Date.class), Mockito.any(long.class)))
.thenReturn(true);
@@ -156,7 +156,7 @@ public void validationTestInvalidDigest(String jwtString, String publicKey, Stri
PowerMockito.mockStatic(JTICache.class);
PowerMockito.mockStatic(JWTUtils.class);
Mockito.when(JTICache.getJtiDataFromCache(Mockito.anyString())).thenReturn(null);
- Mockito.when(JWTUtils.validateJWTSignature(Mockito.any(SignedJWT.class), Mockito.anyString())).
+ Mockito.when(JWTUtils.isValidSignature(Mockito.any(SignedJWT.class), Mockito.anyString())).
thenReturn(true);
Mockito.when(JWTUtils.isValidExpiryTime(Mockito.any(Date.class), Mockito.any(long.class)))
.thenReturn(true);
From 53d4c3bb5b37569ea1e0282b09c97c2b09640676 Mon Sep 17 00:00:00 2001
From: ImalshaD
Date: Wed, 22 May 2024 08:43:37 +0530
Subject: [PATCH 190/281] Comments resolved on response wrapper.
---
.../accelerator/identity/token/wrapper/ResponseWrapper.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/token/wrapper/ResponseWrapper.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/token/wrapper/ResponseWrapper.java
index b1e108c2..916dbdcc 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/token/wrapper/ResponseWrapper.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/token/wrapper/ResponseWrapper.java
@@ -81,3 +81,4 @@ public void setContentType(String type) {
super.setContentType(type);
}
}
+
From 001f76dd05e95a87d245377ec4b7914ba701823d Mon Sep 17 00:00:00 2001
From: ImalshaD
Date: Wed, 22 May 2024 09:22:39 +0530
Subject: [PATCH 191/281] Error messages reformatted.
---
.../identity/app2app/App2AppAuthenticatorConstants.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorConstants.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorConstants.java
index 4dbd95c8..b00f9c5a 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorConstants.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/App2AppAuthenticatorConstants.java
@@ -29,12 +29,12 @@ public class App2AppAuthenticatorConstants {
public static final String DEVICE_VERIFICATION_TOKEN_IDENTIFIER = "deviceVerificationToken";
public static final String SESSION_DATA_KEY = "sessionDataKey";
public static final String APP_AUTH_IDENTIFIER_VALIDATION_EXCEPTION_MESSAGE
- = "Error while validating App Auth Identifier.";
+ = "Error while validating device verification token.";
public static final String ILLEGAL_ARGUMENT_EXCEPTION_MESSAGE
- = "Error while creating user for provided loginHint.";
+ = "Error while creating user for provided login_hint.";
public static final String PARSE_EXCEPTION_MESSAGE = "Error while parsing the provided JWT.";
public static final String PUSH_DEVICE_HANDLER_SERVER_EXCEPTION_MESSAGE
- = "Error occurred in push device handler service: ";
+ = "Error occurred in push device handler service.";
public static final String USER_STORE_EXCEPTION_MESSAGE = "Error while creating authenticated user.";
public static final String PUSH_DEVICE_HANDLER_CLIENT_EXCEPTION_MESSAGE
= "Error occurred in Push Device handler client.";
From 696f2d5a3f7bccb6c2ef1b3313133ff99bd1eb0d Mon Sep 17 00:00:00 2001
From: "Venukshi N. Mendis" <119746771+VenukshiMendis@users.noreply.github.com>
Date: Wed, 22 May 2024 10:07:47 +0530
Subject: [PATCH 192/281] Fix formatting isuses
---
.../openbanking/accelerator/common/util/OpenBankingUtils.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/OpenBankingUtils.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/OpenBankingUtils.java
index d64f5cc4..98593449 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/OpenBankingUtils.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/OpenBankingUtils.java
@@ -51,7 +51,7 @@ public static Object getClassInstanceFromFQN(String classpath) {
log.error("Class not found: " + classpath.replaceAll("[\r\n]", ""));
throw new OpenBankingRuntimeException("Cannot find the defined class", e);
} catch (InstantiationException | InvocationTargetException |
- NoSuchMethodException | IllegalAccessException e) {
+ NoSuchMethodException | IllegalAccessException e) {
//Throwing a runtime exception since we cannot proceed with invalid objects
throw new OpenBankingRuntimeException("Defined class" + classpath + "cannot be instantiated.", e);
}
From 4e52564aaf86a4016fb9475d54debe81d051de68 Mon Sep 17 00:00:00 2001
From: ImalshaD
Date: Wed, 22 May 2024 10:59:07 +0530
Subject: [PATCH 193/281] Comments Resolved.
---
.../app2app/validations/DigestValidator.java | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/DigestValidator.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/DigestValidator.java
index 865d1fdd..6b9c0e4c 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/DigestValidator.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/validations/DigestValidator.java
@@ -57,29 +57,29 @@ public boolean isValid(DeviceVerificationToken deviceVerificationToken,
}
/**
- * Validating the digest of the request.
- * DigestHeader is expected to be the hash of requestObject if request Object is not null.
+ * Validating the digest of the requestObject.
+ * Digest is expected to be the hash of requestObject if request Object is not null.
*
- * @param digestHeader digest header sent with the request
- * @param requestObject the request JWT String
+ * @param digest digest sent in the device verification token
+ * @param requestObject JWT String of the request object
* @return return true if the digest validation is a success, false otherwise
*/
- protected boolean isDigestValid(String digestHeader, String requestObject) {
+ protected boolean isDigestValid(String digest, String requestObject) {
if (StringUtils.isBlank(requestObject)) {
//If the request is null nothing to validate.
return true;
- } else if (StringUtils.isBlank(digestHeader)) {
+ } else if (StringUtils.isBlank(digest)) {
//If request is not empty and digest us empty validation fails.
return false;
}
try {
// Example : SHA-256=EkH8fPgZ2TY2XGns8c5Vvce8h3DB83V+w47zHiyYfiQ=
- String[] digestAttribute = digestHeader.split("=", 2);
+ String[] digestAttribute = digest.split("=", 2);
if (digestAttribute.length != 2) {
- log.error("Invalid digest header.");
+ log.error("Invalid digest.");
return false;
}
// Example : SHA-256
From 31802097d4d29819a9fa74b7e2626e2f0e659b0c Mon Sep 17 00:00:00 2001
From: ImalshaD
Date: Wed, 22 May 2024 13:31:18 +0530
Subject: [PATCH 194/281] Typo Fixed.
---
.../accelerator/identity/app2app/cache/JTICache.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/cache/JTICache.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/cache/JTICache.java
index 9e000970..b32a8796 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/cache/JTICache.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/src/main/java/com/wso2/openbanking/accelerator/identity/app2app/cache/JTICache.java
@@ -39,7 +39,7 @@ public static IdentityCache getInstance() {
if (jtiCacheInstance == null) {
// Synchronize access to ensure thread safety
synchronized (JTICache.class) {
- // Avoids race condition withing threads
+ // Avoids race condition within threads
if (jtiCacheInstance == null) {
jtiCacheInstance = new IdentityCache();
}
From 300527e9956e05fae8dd772c4a806c70780a5781 Mon Sep 17 00:00:00 2001
From: WSO2 Builder
Date: Wed, 22 May 2024 08:35:39 +0000
Subject: [PATCH 195/281] [WSO2 Release] [Jenkins #283] [Release 3.2.5] prepare
release v3.2.5
---
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.common/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.data.publisher/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.gateway/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.identity/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.keymanager/pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.runtime/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.throttler.dao/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.consent.endpoint/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.demo.backend/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.authentication.webapp/pom.xml | 2 +-
open-banking-accelerator/pom.xml | 4 ++--
pom.xml | 4 ++--
react-apps/pom.xml | 2 +-
react-apps/self-care-portal/pom.xml | 2 +-
29 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml b/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml
index 47061554..9b3413ae 100644
--- a/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml
+++ b/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml
@@ -19,7 +19,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5-SNAPSHOT
+ 3.2.5../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
index 90001315..4635ed6c 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5-SNAPSHOT
+ 3.2.5../../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml
index afc3d91d..826fe3aa 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml
@@ -23,7 +23,7 @@
com.wso2.openbanking.accelerator.data.publishercom.wso2.openbanking.accelerator
- 3.2.5-SNAPSHOT
+ 3.2.5../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
index 1c996cd8..2dd6189e 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5-SNAPSHOT
+ 3.2.5../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml
index 31c817f4..df302d91 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5-SNAPSHOT
+ 3.2.5../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
index 47747a5d..365d8c70 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5-SNAPSHOT
+ 3.2.5../../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml
index 02a1c416..a23803c5 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5-SNAPSHOT
+ 3.2.5../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml
index 572a9558..17431ab1 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml
@@ -18,7 +18,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5-SNAPSHOT
+ 3.2.5../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml
index 1029a806..668608b9 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml
@@ -20,7 +20,7 @@
com.wso2.openbanking.accelerator.runtimecom.wso2.openbanking.accelerator
- 3.2.5-SNAPSHOT
+ 3.2.5../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml
index f068ecd0..7381aaea 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5-SNAPSHOT
+ 3.2.5../../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml
index 4ca181b4..08c815bc 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5-SNAPSHOT
+ 3.2.5../../pom.xml
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml
index 4eab4130..8127a6bd 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5-SNAPSHOT
+ 3.2.5../../../pom.xml
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
index 07ff90c2..d610c641 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5-SNAPSHOT
+ 3.2.5../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml
index 97e21a62..beac8c6d 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml
@@ -21,7 +21,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5-SNAPSHOT
+ 3.2.5../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml
index 7dec03bc..72b78f87 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml
@@ -19,7 +19,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5-SNAPSHOT
+ 3.2.5../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml
index 0c4e85a9..86fdfe06 100644
--- a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml
+++ b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5-SNAPSHOT
+ 3.2.5../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml
index 9802f8c6..34c05f25 100644
--- a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml
+++ b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5-SNAPSHOT
+ 3.2.5../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml
index 2e000548..0e63271a 100755
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml
@@ -21,7 +21,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5-SNAPSHOT
+ 3.2.5../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml
index d7b0d816..fe7e87f5 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml
@@ -18,7 +18,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5-SNAPSHOT
+ 3.2.5../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml
index 29de591a..52ee8b9a 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5-SNAPSHOT
+ 3.2.5../../../pom.xml
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
index f896c625..57d18175 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5-SNAPSHOT
+ 3.2.5../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml
index 1f0da4cb..910956cd 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml
@@ -21,7 +21,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5-SNAPSHOT
+ 3.2.5../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml
index 30e47eba..e50f4809 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml
@@ -19,7 +19,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5-SNAPSHOT
+ 3.2.5../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml
index e9643953..2e6dd4a2 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5-SNAPSHOT
+ 3.2.5../../../pom.xml
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml
index 6e90bf75..a0812046 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml
@@ -21,7 +21,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5-SNAPSHOT
+ 3.2.5../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/pom.xml b/open-banking-accelerator/pom.xml
index 4b5c1710..fd22ca52 100644
--- a/open-banking-accelerator/pom.xml
+++ b/open-banking-accelerator/pom.xml
@@ -23,14 +23,14 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.2.5-SNAPSHOT
+ 3.2.5../pom.xmlWSO2 Open Banking Acceleratoropen-banking-acceleratorpom
- 3.2.5-SNAPSHOT
+ 3.2.5components/com.wso2.openbanking.accelerator.common
diff --git a/pom.xml b/pom.xml
index e7ec9cf7..9ff9a008 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,7 +21,7 @@
com.wso2.openbanking.acceleratoropen-bankingpom
- 3.2.5-SNAPSHOT
+ 3.2.5org.wso2
@@ -172,7 +172,7 @@
https://github.com/wso2/financial-open-banking.gitscm:git:https://github.com/wso2/financial-open-banking.gitscm:git:https://github.com/wso2/financial-open-banking.git
- HEAD
+ v3.2.5
diff --git a/react-apps/pom.xml b/react-apps/pom.xml
index 2f331317..5b5383d9 100644
--- a/react-apps/pom.xml
+++ b/react-apps/pom.xml
@@ -23,7 +23,7 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.2.5-SNAPSHOT
+ 3.2.5../pom.xml
diff --git a/react-apps/self-care-portal/pom.xml b/react-apps/self-care-portal/pom.xml
index aba66ad3..7a179ea6 100644
--- a/react-apps/self-care-portal/pom.xml
+++ b/react-apps/self-care-portal/pom.xml
@@ -23,7 +23,7 @@
com.wso2.openbanking.acceleratorreact-apps
- 3.2.5-SNAPSHOT
+ 3.2.5../pom.xml
From 85f205835d9665e685cfcd8640a42ada9ed91371 Mon Sep 17 00:00:00 2001
From: WSO2 Builder
Date: Wed, 22 May 2024 08:35:40 +0000
Subject: [PATCH 196/281] [WSO2 Release] [Jenkins #283] [Release 3.2.5] prepare
for next development iteration
---
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.common/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.data.publisher/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.gateway/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.identity/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.keymanager/pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.runtime/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.throttler.dao/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.consent.endpoint/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.demo.backend/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.authentication.webapp/pom.xml | 2 +-
open-banking-accelerator/pom.xml | 4 ++--
pom.xml | 4 ++--
react-apps/pom.xml | 2 +-
react-apps/self-care-portal/pom.xml | 2 +-
29 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml b/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml
index 9b3413ae..fec503e2 100644
--- a/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml
+++ b/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml
@@ -19,7 +19,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5
+ 3.2.6-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
index 4635ed6c..e57703e7 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5
+ 3.2.6-SNAPSHOT../../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml
index 826fe3aa..d8c7e2d1 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml
@@ -23,7 +23,7 @@
com.wso2.openbanking.accelerator.data.publishercom.wso2.openbanking.accelerator
- 3.2.5
+ 3.2.6-SNAPSHOT../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
index 2dd6189e..1c4111b6 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5
+ 3.2.6-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml
index df302d91..b2cf5657 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5
+ 3.2.6-SNAPSHOT../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
index 365d8c70..0f16490c 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5
+ 3.2.6-SNAPSHOT../../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml
index a23803c5..ddf33d6b 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5
+ 3.2.6-SNAPSHOT../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml
index 17431ab1..8473dbff 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml
@@ -18,7 +18,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5
+ 3.2.6-SNAPSHOT../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml
index 668608b9..f52d7b4c 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml
@@ -20,7 +20,7 @@
com.wso2.openbanking.accelerator.runtimecom.wso2.openbanking.accelerator
- 3.2.5
+ 3.2.6-SNAPSHOT../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml
index 7381aaea..da0c13d9 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5
+ 3.2.6-SNAPSHOT../../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml
index 08c815bc..1c424048 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5
+ 3.2.6-SNAPSHOT../../pom.xml
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml
index 8127a6bd..9afb92fc 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5
+ 3.2.6-SNAPSHOT../../../pom.xml
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
index d610c641..36ee8b35 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5
+ 3.2.6-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml
index beac8c6d..809fcaba 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml
@@ -21,7 +21,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5
+ 3.2.6-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml
index 72b78f87..0fa5af5c 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml
@@ -19,7 +19,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5
+ 3.2.6-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml
index 86fdfe06..f873c567 100644
--- a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml
+++ b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5
+ 3.2.6-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml
index 34c05f25..4bd6535b 100644
--- a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml
+++ b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5
+ 3.2.6-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml
index 0e63271a..9d521994 100755
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml
@@ -21,7 +21,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5
+ 3.2.6-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml
index fe7e87f5..f5b4ac6b 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml
@@ -18,7 +18,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5
+ 3.2.6-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml
index 52ee8b9a..35cb44a6 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5
+ 3.2.6-SNAPSHOT../../../pom.xml
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
index 57d18175..a6858d8d 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5
+ 3.2.6-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml
index 910956cd..0fd65679 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml
@@ -21,7 +21,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5
+ 3.2.6-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml
index e50f4809..436e487b 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml
@@ -19,7 +19,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5
+ 3.2.6-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml
index 2e6dd4a2..412d8091 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5
+ 3.2.6-SNAPSHOT../../../pom.xml
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml
index a0812046..033a0cd2 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml
@@ -21,7 +21,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.5
+ 3.2.6-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/pom.xml b/open-banking-accelerator/pom.xml
index fd22ca52..006efbca 100644
--- a/open-banking-accelerator/pom.xml
+++ b/open-banking-accelerator/pom.xml
@@ -23,14 +23,14 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.2.5
+ 3.2.6-SNAPSHOT../pom.xmlWSO2 Open Banking Acceleratoropen-banking-acceleratorpom
- 3.2.5
+ 3.2.6-SNAPSHOTcomponents/com.wso2.openbanking.accelerator.common
diff --git a/pom.xml b/pom.xml
index 9ff9a008..31f0e48d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,7 +21,7 @@
com.wso2.openbanking.acceleratoropen-bankingpom
- 3.2.5
+ 3.2.6-SNAPSHOTorg.wso2
@@ -172,7 +172,7 @@
https://github.com/wso2/financial-open-banking.gitscm:git:https://github.com/wso2/financial-open-banking.gitscm:git:https://github.com/wso2/financial-open-banking.git
- v3.2.5
+ HEAD
diff --git a/react-apps/pom.xml b/react-apps/pom.xml
index 5b5383d9..93850a09 100644
--- a/react-apps/pom.xml
+++ b/react-apps/pom.xml
@@ -23,7 +23,7 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.2.5
+ 3.2.6-SNAPSHOT../pom.xml
diff --git a/react-apps/self-care-portal/pom.xml b/react-apps/self-care-portal/pom.xml
index 7a179ea6..eeb48be1 100644
--- a/react-apps/self-care-portal/pom.xml
+++ b/react-apps/self-care-portal/pom.xml
@@ -23,7 +23,7 @@
com.wso2.openbanking.acceleratorreact-apps
- 3.2.5
+ 3.2.6-SNAPSHOT../pom.xml
From 991e96c5f902ce5f3d2c7f27bd3a296453144e32 Mon Sep 17 00:00:00 2001
From: kalpana
Date: Wed, 29 May 2024 12:13:17 +0530
Subject: [PATCH 197/281] Resolving comments
---
.../consent/extensions/validate/VRPSubmissionTest.java | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/validate/VRPSubmissionTest.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/validate/VRPSubmissionTest.java
index 35dd5a31..424faee3 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/validate/VRPSubmissionTest.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/validate/VRPSubmissionTest.java
@@ -105,17 +105,17 @@ public void initClass() throws ReflectiveOperationException {
@BeforeMethod
public void initMethod() {
- OpenBankingConfigParser openBankingUKConfigParserMock = mock(OpenBankingConfigParser.class);
- doReturn(configMap).when(openBankingUKConfigParserMock).getConfiguration();
+ OpenBankingConfigParser openBankingConfigParserMock = mock(OpenBankingConfigParser.class);
+ doReturn(configMap).when(openBankingConfigParserMock).getConfiguration();
PowerMockito.mockStatic(OpenBankingConfigParser.class);
- PowerMockito.when(OpenBankingConfigParser.getInstance()).thenReturn(openBankingUKConfigParserMock);
+ PowerMockito.when(OpenBankingConfigParser.getInstance()).thenReturn(openBankingConfigParserMock);
- OpenBankingConfigParser openBankingConfigParserMock = mock(OpenBankingConfigParser.class);
+ OpenBankingConfigParser openBankingConfigParsersMock = mock(OpenBankingConfigParser.class);
doReturn(configMap).when(openBankingConfigParserMock).getConfiguration();
PowerMockito.mockStatic(OpenBankingConfigParser.class);
- PowerMockito.when(OpenBankingConfigParser.getInstance()).thenReturn(openBankingConfigParserMock);
+ PowerMockito.when(OpenBankingConfigParser.getInstance()).thenReturn(openBankingConfigParsersMock);
}
@ObjectFactory
From 83628737d044a1505bcd0c8bffa93f0cf094dacb Mon Sep 17 00:00:00 2001
From: kalpana
Date: Fri, 31 May 2024 12:01:00 +0530
Subject: [PATCH 198/281] Resolving comments
---
.../impl/DefaultConsentValidator.java | 17 +++--
.../impl/VRPSubmissionPayloadValidator.java | 8 +-
.../validate/util/ConsentValidatorUtil.java | 15 +++-
.../validate/VRPSubmissionTest.java | 73 -------------------
4 files changed, 25 insertions(+), 88 deletions(-)
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/DefaultConsentValidator.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/DefaultConsentValidator.java
index faab62fe..416f5b3b 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/DefaultConsentValidator.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/DefaultConsentValidator.java
@@ -414,21 +414,22 @@ private void validateVRPSubmission(ConsentValidateData consentValidateData, JSON
}
JSONObject submissionJson = consentValidateData.getPayload();
- JSONObject submissionData = (JSONObject) submissionJson.get(ConsentExtensionConstants.DATA);
JSONObject dataValidationResults = VRPSubmissionPayloadValidator.validateSubmissionData(submissionJson);
if (!Boolean.parseBoolean(dataValidationResults.
getAsString(ConsentExtensionConstants.IS_VALID_PAYLOAD))) {
- ConsentValidatorUtil.getErrorAndLog(dataValidationResults, consentValidationResult);
+ ConsentValidatorUtil.getErrorMessage(dataValidationResults, consentValidationResult);
return;
}
+ JSONObject submissionData = (JSONObject) submissionJson.get(ConsentExtensionConstants.DATA);
+
JSONObject initiationParameterValidationResults = VRPSubmissionPayloadValidator.
validateInitiationParameter(submissionData);
if (!Boolean.parseBoolean(initiationParameterValidationResults.
getAsString(ConsentExtensionConstants.IS_VALID_PAYLOAD))) {
log.error(initiationParameterValidationResults.getAsString(ConsentExtensionConstants.ERROR_MESSAGE));
- ConsentValidatorUtil.getErrorAndLog(initiationParameterValidationResults, consentValidationResult);
+ ConsentValidatorUtil.getErrorMessage(initiationParameterValidationResults, consentValidationResult);
return;
}
@@ -437,7 +438,7 @@ private void validateVRPSubmission(ConsentValidateData consentValidateData, JSON
if (!Boolean.parseBoolean(instructionParameterValidationResults.
getAsString(ConsentExtensionConstants.IS_VALID_PAYLOAD))) {
log.error(instructionParameterValidationResults.getAsString(ConsentExtensionConstants.ERROR_MESSAGE));
- ConsentValidatorUtil.getErrorAndLog(instructionParameterValidationResults, consentValidationResult);
+ ConsentValidatorUtil.getErrorMessage(instructionParameterValidationResults, consentValidationResult);
return;
}
@@ -463,7 +464,7 @@ private void validateVRPSubmission(ConsentValidateData consentValidateData, JSON
if (!Boolean.parseBoolean(initiationValidationResult.
getAsString(ConsentExtensionConstants.IS_VALID_PAYLOAD))) {
- ConsentValidatorUtil.getErrorAndLog(initiationValidationResult, consentValidationResult);
+ ConsentValidatorUtil.getErrorMessage(initiationValidationResult, consentValidationResult);
return;
}
@@ -472,14 +473,14 @@ private void validateVRPSubmission(ConsentValidateData consentValidateData, JSON
if (!Boolean.parseBoolean(instructionValidationResult.
getAsString(ConsentExtensionConstants.IS_VALID_PAYLOAD))) {
- ConsentValidatorUtil.getErrorAndLog(instructionValidationResult, consentValidationResult);
+ ConsentValidatorUtil.getErrorMessage(instructionValidationResult, consentValidationResult);
return;
}
JSONObject riskParameterValidationResults = VRPSubmissionPayloadValidator.validateRiskParameter(submissionJson);
if (!Boolean.parseBoolean(riskParameterValidationResults.
getAsString(ConsentExtensionConstants.IS_VALID_PAYLOAD))) {
- ConsentValidatorUtil.getErrorAndLog(riskParameterValidationResults, consentValidationResult);
+ ConsentValidatorUtil.getErrorMessage(riskParameterValidationResults, consentValidationResult);
return;
}
@@ -490,7 +491,7 @@ private void validateVRPSubmission(ConsentValidateData consentValidateData, JSON
if (!Boolean.parseBoolean(riskValidationResult.
getAsString(ConsentExtensionConstants.IS_VALID_PAYLOAD))) {
- ConsentValidatorUtil.getErrorAndLog(riskValidationResult, consentValidationResult);
+ ConsentValidatorUtil.getErrorMessage(riskValidationResult, consentValidationResult);
return;
}
consentValidationResult.setValid(true);
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/VRPSubmissionPayloadValidator.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/VRPSubmissionPayloadValidator.java
index 5e1e16f7..c22ea5fd 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/VRPSubmissionPayloadValidator.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/VRPSubmissionPayloadValidator.java
@@ -45,7 +45,7 @@ public static JSONObject validateInitiation(JSONObject initiationOfSubmission,
JSONObject initiationParameterOfConsentInitiation) {
JSONObject validationResult = new JSONObject();
- validationResult.put(ConsentExtensionConstants.IS_VALID_PAYLOAD, true);
+ validationResult.put(ConsentExtensionConstants.IS_VALID_PAYLOAD, false);
validationResult.put(ConsentExtensionConstants.ERROR_CODE, "");
validationResult.put(ConsentExtensionConstants.ERROR_MESSAGE, "");
@@ -167,6 +167,7 @@ public static JSONObject validateInitiation(JSONObject initiationOfSubmission,
}
}
+ validationResult.put(ConsentExtensionConstants.IS_VALID_PAYLOAD, true);
return validationResult;
}
@@ -183,7 +184,7 @@ public static JSONObject validateInstruction(JSONObject submission,
JSONObject initiation) {
JSONObject validationResult = new JSONObject();
- validationResult.put(ConsentExtensionConstants.IS_VALID_PAYLOAD, true);
+ validationResult.put(ConsentExtensionConstants.IS_VALID_PAYLOAD, false);
validationResult.put(ConsentExtensionConstants.ERROR_CODE, "");
validationResult.put(ConsentExtensionConstants.ERROR_MESSAGE, "");
@@ -319,6 +320,7 @@ public static JSONObject validateInstruction(JSONObject submission,
ErrorConstants.INITIATION_REMITTANCE_INFO_PARAMETER_NOT_FOUND);
}
}
+ validationResult.put(ConsentExtensionConstants.IS_VALID_PAYLOAD, true);
return validationResult;
}
@@ -490,7 +492,7 @@ public static JSONObject validateSubmissionData(JSONObject submissionJson) {
!(submissionJson.get(ConsentExtensionConstants.DATA) instanceof JSONObject)) {
log.error(ErrorConstants.DATA_NOT_FOUND);
return ConsentValidatorUtil.getValidationResult(ErrorConstants.FIELD_MISSING,
- ErrorConstants.DATA_NOT_JSON_ERROR);
+ ErrorConstants.DATA_NOT_FOUND);
}
return validationResult;
}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/util/ConsentValidatorUtil.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/util/ConsentValidatorUtil.java
index a15e4e19..9b93d448 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/util/ConsentValidatorUtil.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/util/ConsentValidatorUtil.java
@@ -72,18 +72,25 @@ public static JSONObject getValidationResult(String errorCode, String errorMessa
return validationResult;
}
- public static JSONObject getErrorAndLog(JSONObject errorResult, ConsentValidationResult consentValidationResult) {
+
+ /**
+ * Populates the provided consent validation result object with error information and constructs a JSON object
+ * indicating an invalid payload.
+ *
+ * @param errorResult the JSONObject containing error details, specifically error message and error code
+ * @param consentValidationResult the ConsentValidationResult object to be updated with error details
+ * @return validationResult
+ */
+ public static JSONObject getErrorMessage(JSONObject errorResult, ConsentValidationResult consentValidationResult) {
JSONObject validationResult = new JSONObject();
- validationResult.put(ConsentExtensionConstants.IS_VALID_PAYLOAD, true);
+ validationResult.put(ConsentExtensionConstants.IS_VALID_PAYLOAD, false);
validationResult.put(ConsentExtensionConstants.ERROR_CODE, "");
validationResult.put(ConsentExtensionConstants.ERROR_MESSAGE, "");
String errorMessage = errorResult.getAsString(ConsentExtensionConstants.ERROR_MESSAGE);
String errorCode = errorResult.getAsString(ConsentExtensionConstants.ERROR_CODE);
- // log.error(errorMessage);
-
consentValidationResult.setErrorMessage(errorMessage);
consentValidationResult.setErrorCode(errorCode);
consentValidationResult.setHttpCode(HttpStatus.SC_BAD_REQUEST);
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/validate/VRPSubmissionTest.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/validate/VRPSubmissionTest.java
index 424faee3..4981307c 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/validate/VRPSubmissionTest.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/validate/VRPSubmissionTest.java
@@ -570,35 +570,6 @@ public void testValidateVRPSubmissionWithoutRemittanceInfoMisMatch() throws Pars
Assert.assertEquals(consentValidationResult.getHttpCode(), 400);
}
- @Test(dataProvider = "VRPInvalidSubmissionPayloadsDataProvider",
- dataProviderClass = ConsentExtensionDataProvider.class)
- public void testValidateVRPSubmissionForInvalidInstruction(String payload) throws ParseException {
-
- doReturn(authorizationResources).when(detailedConsentResourceMock).getAuthorizationResources();
- doReturn(ConsentValidateTestConstants.CLIENT_ID).when(detailedConsentResourceMock).getClientID();
- doReturn(detailedConsentResourceMock).when(consentValidateDataMock).getComprehensiveConsent();
- doReturn(ConsentExtensionConstants.VRP).when(detailedConsentResourceMock).getConsentType();
- doReturn(ConsentValidateTestConstants.VRP_INITIATION).when(detailedConsentResourceMock).getReceipt();
- doReturn(ConsentExtensionConstants.AUTHORIZED_STATUS).when(detailedConsentResourceMock).getCurrentStatus();
-
- doReturn(getVRPConsentAttributes()).when(detailedConsentResourceMock).getConsentAttributes();
- doReturn(ConsentValidateTestConstants.CONSENT_ID).when(detailedConsentResourceMock).getConsentID();
- doReturn(ConsentValidateTestConstants.USER_ID).when(consentValidateDataMock).getUserId();
- doReturn(ConsentValidateTestConstants.CLIENT_ID).when(consentValidateDataMock).getClientId();
-
- doReturn(ConsentValidateTestConstants.VRP_PATH).when(consentValidateDataMock).getRequestPath();
- doReturn(resourceParams).when(consentValidateDataMock).getResourceParams();
- doReturn(headers).when(consentValidateDataMock).getHeaders();
- doReturn(ConsentValidateTestConstants.CONSENT_ID).when(consentValidateDataMock).getConsentId();
- JSONObject submissionPayload = (JSONObject) new JSONParser(JSONParser.MODE_PERMISSIVE).parse(payload);
- doReturn(submissionPayload).when(consentValidateDataMock).getPayload();
-
- ConsentValidationResult consentValidationResult = new ConsentValidationResult();
- consentValidator.validate(consentValidateDataMock, consentValidationResult);
-
- Assert.assertFalse(consentValidationResult.isValid());
- }
-//
@Test(dataProvider = "VRPInvalidInitiationSubmissionPayloadsDataProvider",
dataProviderClass = ConsentExtensionDataProvider.class)
public void testValidateVRPSubmissionForInvalidInitiation(String payload) throws ParseException {
@@ -713,49 +684,5 @@ public void testValidateVRPSubmissionWithIntegerEndToEndIdentification() throws
Assert.assertEquals(consentValidationResult.getErrorCode(), ErrorConstants.FIELD_INVALID);
Assert.assertEquals(consentValidationResult.getHttpCode(), 400);
}
-
- @Test
- public void testValidateVRPSubmissionWithoutInstructionRemittanceInfoMisMatch() throws ParseException,
- ConsentManagementException {
-
- doReturn(authorizationResources).when(detailedConsentResourceMock).getAuthorizationResources();
- doReturn(ConsentValidateTestConstants.CLIENT_ID).when(detailedConsentResourceMock).getClientID();
- doReturn(detailedConsentResourceMock).when(consentValidateDataMock).getComprehensiveConsent();
- doReturn(ConsentExtensionConstants.VRP).when(detailedConsentResourceMock).getConsentType();
- doReturn(ConsentValidateTestConstants.VRP_INITIATION).when(detailedConsentResourceMock).getReceipt();
- doReturn(ConsentExtensionConstants.AUTHORIZED_STATUS).when(detailedConsentResourceMock).getCurrentStatus();
-
- doReturn(getVRPConsentAttributes()).when(detailedConsentResourceMock).getConsentAttributes();
- doReturn(ConsentValidateTestConstants.CONSENT_ID).when(detailedConsentResourceMock).getConsentID();
- doReturn(ConsentValidateTestConstants.USER_ID).when(consentValidateDataMock).getUserId();
- doReturn(ConsentValidateTestConstants.CLIENT_ID).when(consentValidateDataMock).getClientId();
-
- doReturn(ConsentValidateTestConstants.VRP_PATH).when(consentValidateDataMock).getRequestPath();
- doReturn(resourceParams).when(consentValidateDataMock).getResourceParams();
- doReturn(headers).when(consentValidateDataMock).getHeaders();
- doReturn(ConsentValidateTestConstants.CONSENT_ID).when(consentValidateDataMock).getConsentId();
- JSONObject submissionPayload = (JSONObject) new JSONParser(JSONParser.MODE_PERMISSIVE)
- .parse(ConsentValidateTestConstants.VRP_SUBMISSION_WITHOUT_INSTRUCTION_REMITTANCE_INFO_MISMATCH);
- doReturn(submissionPayload).when(consentValidateDataMock).getPayload();
-
- doReturn(ConsentExtensionTestUtils.getConsentAttributes("vrp"))
- .when(consentCoreServiceMock).getConsentAttributes(Mockito.anyString());
- doReturn(true).when(consentCoreServiceMock).deleteConsentAttributes(Mockito.anyString(),
- Mockito.>anyObject());
- doReturn(true).when(consentCoreServiceMock).storeConsentAttributes(Mockito.anyString(),
- Mockito.>anyObject());
-
- PowerMockito.mockStatic(ConsentServiceUtil.class);
- PowerMockito.when(ConsentServiceUtil.getConsentService()).thenReturn(consentCoreServiceMock);
-
- ConsentValidationResult consentValidationResult = new ConsentValidationResult();
- consentValidator.validate(consentValidateDataMock, consentValidationResult);
-
- Assert.assertFalse(consentValidationResult.isValid());
- Assert.assertEquals(consentValidationResult.getErrorMessage(),
- ErrorConstants.REMITTANCE_INFO_MISMATCH);
- Assert.assertEquals(consentValidationResult.getErrorCode(), ErrorConstants.RESOURCE_CONSENT_MISMATCH);
- Assert.assertEquals(consentValidationResult.getHttpCode(), 400);
- }
}
From dc8a94b45647c5d10b6625a302b36880a29227f8 Mon Sep 17 00:00:00 2001
From: kalpana
Date: Fri, 31 May 2024 12:20:56 +0530
Subject: [PATCH 199/281] Resolving comments
---
.../impl/DefaultConsentValidator.java | 21 ++++++++++++-------
.../validate/util/ConsentValidatorUtil.java | 3 ++-
2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/DefaultConsentValidator.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/DefaultConsentValidator.java
index 416f5b3b..8e807620 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/DefaultConsentValidator.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/DefaultConsentValidator.java
@@ -418,7 +418,8 @@ private void validateVRPSubmission(ConsentValidateData consentValidateData, JSON
JSONObject dataValidationResults = VRPSubmissionPayloadValidator.validateSubmissionData(submissionJson);
if (!Boolean.parseBoolean(dataValidationResults.
getAsString(ConsentExtensionConstants.IS_VALID_PAYLOAD))) {
- ConsentValidatorUtil.getErrorMessage(dataValidationResults, consentValidationResult);
+ ConsentValidatorUtil.setErrorMessageForConsentValidationResult(dataValidationResults,
+ consentValidationResult);
return;
}
@@ -429,7 +430,8 @@ private void validateVRPSubmission(ConsentValidateData consentValidateData, JSON
if (!Boolean.parseBoolean(initiationParameterValidationResults.
getAsString(ConsentExtensionConstants.IS_VALID_PAYLOAD))) {
log.error(initiationParameterValidationResults.getAsString(ConsentExtensionConstants.ERROR_MESSAGE));
- ConsentValidatorUtil.getErrorMessage(initiationParameterValidationResults, consentValidationResult);
+ ConsentValidatorUtil.setErrorMessageForConsentValidationResult(initiationParameterValidationResults,
+ consentValidationResult);
return;
}
@@ -438,7 +440,8 @@ private void validateVRPSubmission(ConsentValidateData consentValidateData, JSON
if (!Boolean.parseBoolean(instructionParameterValidationResults.
getAsString(ConsentExtensionConstants.IS_VALID_PAYLOAD))) {
log.error(instructionParameterValidationResults.getAsString(ConsentExtensionConstants.ERROR_MESSAGE));
- ConsentValidatorUtil.getErrorMessage(instructionParameterValidationResults, consentValidationResult);
+ ConsentValidatorUtil.setErrorMessageForConsentValidationResult(instructionParameterValidationResults,
+ consentValidationResult);
return;
}
@@ -464,7 +467,8 @@ private void validateVRPSubmission(ConsentValidateData consentValidateData, JSON
if (!Boolean.parseBoolean(initiationValidationResult.
getAsString(ConsentExtensionConstants.IS_VALID_PAYLOAD))) {
- ConsentValidatorUtil.getErrorMessage(initiationValidationResult, consentValidationResult);
+ ConsentValidatorUtil.setErrorMessageForConsentValidationResult(initiationValidationResult,
+ consentValidationResult);
return;
}
@@ -473,14 +477,16 @@ private void validateVRPSubmission(ConsentValidateData consentValidateData, JSON
if (!Boolean.parseBoolean(instructionValidationResult.
getAsString(ConsentExtensionConstants.IS_VALID_PAYLOAD))) {
- ConsentValidatorUtil.getErrorMessage(instructionValidationResult, consentValidationResult);
+ ConsentValidatorUtil.setErrorMessageForConsentValidationResult(instructionValidationResult,
+ consentValidationResult);
return;
}
JSONObject riskParameterValidationResults = VRPSubmissionPayloadValidator.validateRiskParameter(submissionJson);
if (!Boolean.parseBoolean(riskParameterValidationResults.
getAsString(ConsentExtensionConstants.IS_VALID_PAYLOAD))) {
- ConsentValidatorUtil.getErrorMessage(riskParameterValidationResults, consentValidationResult);
+ ConsentValidatorUtil.setErrorMessageForConsentValidationResult(riskParameterValidationResults,
+ consentValidationResult);
return;
}
@@ -491,7 +497,8 @@ private void validateVRPSubmission(ConsentValidateData consentValidateData, JSON
if (!Boolean.parseBoolean(riskValidationResult.
getAsString(ConsentExtensionConstants.IS_VALID_PAYLOAD))) {
- ConsentValidatorUtil.getErrorMessage(riskValidationResult, consentValidationResult);
+ ConsentValidatorUtil.setErrorMessageForConsentValidationResult(riskValidationResult,
+ consentValidationResult);
return;
}
consentValidationResult.setValid(true);
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/util/ConsentValidatorUtil.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/util/ConsentValidatorUtil.java
index 9b93d448..5558f2e6 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/util/ConsentValidatorUtil.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/util/ConsentValidatorUtil.java
@@ -81,7 +81,8 @@ public static JSONObject getValidationResult(String errorCode, String errorMessa
* @param consentValidationResult the ConsentValidationResult object to be updated with error details
* @return validationResult
*/
- public static JSONObject getErrorMessage(JSONObject errorResult, ConsentValidationResult consentValidationResult) {
+ public static JSONObject setErrorMessageForConsentValidationResult(JSONObject errorResult
+ , ConsentValidationResult consentValidationResult) {
JSONObject validationResult = new JSONObject();
validationResult.put(ConsentExtensionConstants.IS_VALID_PAYLOAD, false);
From 983db0755dee3485349c5371280e4388d0d49b3f Mon Sep 17 00:00:00 2001
From: kalpana
Date: Fri, 31 May 2024 13:31:53 +0530
Subject: [PATCH 200/281] Resolving comments - adding inline comments and
method comments
---
.../extensions/validate/impl/DefaultConsentValidator.java | 3 +++
.../validate/impl/VRPSubmissionPayloadValidator.java | 5 +++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/DefaultConsentValidator.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/DefaultConsentValidator.java
index 8e807620..b6cc0db4 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/DefaultConsentValidator.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/DefaultConsentValidator.java
@@ -472,6 +472,9 @@ private void validateVRPSubmission(ConsentValidateData consentValidateData, JSON
return;
}
+ // Here the requestInitiation is passed as a parameter in order to compare the creditor account in
+ // the initiation payload present under the initiation parameter with the submission payload present under the
+ // instruction parameter.
JSONObject instructionValidationResult = VRPSubmissionPayloadValidator.
validateInstruction(submissionInstruction, requestInitiation);
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/VRPSubmissionPayloadValidator.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/VRPSubmissionPayloadValidator.java
index c22ea5fd..fa22789d 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/VRPSubmissionPayloadValidator.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/VRPSubmissionPayloadValidator.java
@@ -174,8 +174,9 @@ public static JSONObject validateInitiation(JSONObject initiationOfSubmission,
/**
* Validates the instruction between submission and initiation JSONObjects.
*
- * @param submission The instruction submission JSONObject from submission request.
- * @param initiation The instruction initiation JSONObject from initiation request.
+ * @param submission The submission JSONObject from submission request.
+ * @param initiation The initiation JSONObject from initiation request, here we consider the initiation parameter
+ * since the creditor account from the initiation request need to be retrieved.
* @return A JSONObject indicating the validation result. It contains a boolean value under the key
* ConsentExtensionConstants.IS_VALID_PAYLOAD, indicating whether the payload is valid. If the
* validation fails, it returns a JSONObject containing error details with keys defined in ErrorConstants.
From 1645a724f960e50c5b3339d22ba7cc01bd034bdf Mon Sep 17 00:00:00 2001
From: Anju Chamantha
Date: Mon, 3 Jun 2024 16:37:30 +0530
Subject: [PATCH 201/281] Event Notification bug fix for postgresql
---
.../constants/EventNotificationConstants.java | 1 +
.../service/dao/EventSubscriptionDAOImpl.java | 8 ++++-
...efaultEventSubscriptionServiceHandler.java | 34 +++++++++----------
.../dao/EventSubscriptionDAOImplTests.java | 10 ++++++
.../endpoint/util/EventSubscriptionUtils.java | 6 ++--
5 files changed, 38 insertions(+), 21 deletions(-)
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/constants/EventNotificationConstants.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/constants/EventNotificationConstants.java
index 835e2248..e3e09261 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/constants/EventNotificationConstants.java
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/constants/EventNotificationConstants.java
@@ -115,4 +115,5 @@ public class EventNotificationConstants {
public static final String EVENT_SUBSCRIPTIONS_NOT_FOUND = "Event subscriptions not found for the given client id.";
public static final String ERROR_HANDLING_EVENT_SUBSCRIPTION = "Error occurred while handling the event " +
"subscription request";
+ public static final String POSTGRE_SQL = "PostgreSQL";
}
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/EventSubscriptionDAOImpl.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/EventSubscriptionDAOImpl.java
index 7f86e8fa..cea47a18 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/EventSubscriptionDAOImpl.java
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/EventSubscriptionDAOImpl.java
@@ -60,13 +60,19 @@ public EventSubscription storeEventSubscription(Connection connection, EventSubs
final String sql = sqlStatements.storeEventSubscriptionQuery();
try (PreparedStatement storeEventSubscriptionStatement = connection.prepareStatement(sql)) {
+ String driverName = connection.getMetaData().getDriverName();
storeEventSubscriptionStatement.setString(1, eventSubscription.getSubscriptionId());
storeEventSubscriptionStatement.setString(2, eventSubscription.getClientId());
storeEventSubscriptionStatement.setString(3, eventSubscription.getCallbackUrl());
storeEventSubscriptionStatement.setLong(4, eventSubscription.getTimeStamp());
storeEventSubscriptionStatement.setString(5, eventSubscription.getSpecVersion());
storeEventSubscriptionStatement.setString(6, eventSubscription.getStatus());
- storeEventSubscriptionStatement.setString(7, eventSubscription.getRequestData());
+ if (driverName.contains(EventNotificationConstants.POSTGRE_SQL)) {
+ storeEventSubscriptionStatement.setObject(7, eventSubscription.getRequestData(),
+ java.sql.Types.OTHER);
+ } else {
+ storeEventSubscriptionStatement.setString(7, eventSubscription.getRequestData());
+ }
storeSubscriptionAffectedRows = storeEventSubscriptionStatement.executeUpdate();
if (storeSubscriptionAffectedRows == 0) {
log.error("Failed to store the event notification subscription.");
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/DefaultEventSubscriptionServiceHandler.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/DefaultEventSubscriptionServiceHandler.java
index 406d2a64..e8a281d4 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/DefaultEventSubscriptionServiceHandler.java
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/handler/DefaultEventSubscriptionServiceHandler.java
@@ -28,7 +28,7 @@
import net.minidev.json.JSONObject;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.springframework.http.HttpStatus;
+import org.apache.http.HttpStatus;
import java.util.ArrayList;
import java.util.List;
@@ -65,13 +65,13 @@ public EventSubscriptionResponse createEventSubscription(EventSubscriptionDTO ev
try {
EventSubscription createEventSubscriptionResponse = eventSubscriptionService.
createEventSubscription(eventSubscription);
- eventSubscriptionResponse.setStatus(HttpStatus.CREATED.value());
+ eventSubscriptionResponse.setStatus(HttpStatus.SC_CREATED);
eventSubscriptionResponse.
setResponseBody(mapSubscriptionModelToResponseJson(createEventSubscriptionResponse));
return eventSubscriptionResponse;
} catch (OBEventNotificationException e) {
log.error("Error occurred while creating event subscription", e);
- eventSubscriptionResponse.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
+ eventSubscriptionResponse.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
eventSubscriptionResponse.setErrorResponse(EventNotificationServiceUtil.getErrorDTO(
EventNotificationConstants.INVALID_REQUEST, e.getMessage()));
return eventSubscriptionResponse;
@@ -99,17 +99,17 @@ public EventSubscriptionResponse getEventSubscription(String clientId, String su
try {
EventSubscription eventSubscription = eventSubscriptionService.
getEventSubscriptionBySubscriptionId(subscriptionId);
- eventSubscriptionResponse.setStatus(HttpStatus.OK.value());
+ eventSubscriptionResponse.setStatus(HttpStatus.SC_OK);
eventSubscriptionResponse.setResponseBody(mapSubscriptionModelToResponseJson(eventSubscription));
return eventSubscriptionResponse;
} catch (OBEventNotificationException e) {
log.error("Error occurred while retrieving event subscription", e);
if (e.getMessage().equals(EventNotificationConstants.EVENT_SUBSCRIPTION_NOT_FOUND)) {
- eventSubscriptionResponse.setStatus(HttpStatus.BAD_REQUEST.value());
+ eventSubscriptionResponse.setStatus(HttpStatus.SC_BAD_REQUEST);
eventSubscriptionResponse.setErrorResponse(EventNotificationServiceUtil.getErrorDTO(
EventNotificationConstants.INVALID_REQUEST, e.getMessage()));
} else {
- eventSubscriptionResponse.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
+ eventSubscriptionResponse.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
eventSubscriptionResponse.setErrorResponse(EventNotificationServiceUtil.getErrorDTO(
EventNotificationConstants.INVALID_REQUEST, e.getMessage()));
}
@@ -139,12 +139,12 @@ public EventSubscriptionResponse getAllEventSubscriptions(String clientId) {
for (EventSubscription eventSubscription : eventSubscriptionList) {
eventSubscriptionResponseList.add(mapSubscriptionModelToResponseJson(eventSubscription));
}
- eventSubscriptionResponse.setStatus(HttpStatus.OK.value());
+ eventSubscriptionResponse.setStatus(HttpStatus.SC_OK);
eventSubscriptionResponse.setResponseBody(eventSubscriptionResponseList);
return eventSubscriptionResponse;
} catch (OBEventNotificationException e) {
log.error("Error occurred while retrieving event subscriptions", e);
- eventSubscriptionResponse.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
+ eventSubscriptionResponse.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
eventSubscriptionResponse.setErrorResponse(EventNotificationServiceUtil.getErrorDTO(
EventNotificationConstants.INVALID_REQUEST, e.getMessage()));
return eventSubscriptionResponse;
@@ -175,12 +175,12 @@ public EventSubscriptionResponse getEventSubscriptionsByEventType(String clientI
for (EventSubscription eventSubscription : eventSubscriptionList) {
eventSubscriptionResponseList.add(mapSubscriptionModelToResponseJson(eventSubscription));
}
- eventSubscriptionResponse.setStatus(HttpStatus.OK.value());
+ eventSubscriptionResponse.setStatus(HttpStatus.SC_OK);
eventSubscriptionResponse.setResponseBody(eventSubscriptionResponseList);
return eventSubscriptionResponse;
} catch (OBEventNotificationException e) {
log.error("Error occurred while retrieving event subscriptions", e);
- eventSubscriptionResponse.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
+ eventSubscriptionResponse.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
eventSubscriptionResponse.setErrorResponse(EventNotificationServiceUtil.getErrorDTO(
EventNotificationConstants.INVALID_REQUEST, e.getMessage()));
return eventSubscriptionResponse;
@@ -208,13 +208,13 @@ public EventSubscriptionResponse updateEventSubscription(EventSubscriptionDTO ev
try {
Boolean isUpdated = eventSubscriptionService.updateEventSubscription(eventSubscription);
if (!isUpdated) {
- eventSubscriptionResponse.setStatus(HttpStatus.BAD_REQUEST.value());
+ eventSubscriptionResponse.setStatus(HttpStatus.SC_BAD_REQUEST);
eventSubscriptionResponse.setErrorResponse(EventNotificationServiceUtil.getErrorDTO(
EventNotificationConstants.INVALID_REQUEST,
"Event subscription not found."));
return eventSubscriptionResponse;
}
- eventSubscriptionResponse.setStatus(HttpStatus.OK.value());
+ eventSubscriptionResponse.setStatus(HttpStatus.SC_OK);
EventSubscription eventSubscriptionUpdateResponse = eventSubscriptionService.
getEventSubscriptionBySubscriptionId(eventSubscriptionUpdateRequestDto.getSubscriptionId());
eventSubscriptionResponse.
@@ -222,7 +222,7 @@ public EventSubscriptionResponse updateEventSubscription(EventSubscriptionDTO ev
return eventSubscriptionResponse;
} catch (OBEventNotificationException e) {
log.error("Error occurred while updating event subscription", e);
- eventSubscriptionResponse.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
+ eventSubscriptionResponse.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
eventSubscriptionResponse.setErrorResponse(EventNotificationServiceUtil.getErrorDTO(
EventNotificationConstants.INVALID_REQUEST, e.getMessage()));
return eventSubscriptionResponse;
@@ -247,17 +247,17 @@ public EventSubscriptionResponse deleteEventSubscription(String clientId, String
try {
Boolean isDeleted = eventSubscriptionService.deleteEventSubscription(subscriptionId);
if (!isDeleted) {
- eventSubscriptionResponse.setStatus(HttpStatus.BAD_REQUEST.value());
+ eventSubscriptionResponse.setStatus(HttpStatus.SC_BAD_REQUEST);
eventSubscriptionResponse.setErrorResponse(EventNotificationServiceUtil.getErrorDTO(
EventNotificationConstants.INVALID_REQUEST,
"Event subscription not found"));
return eventSubscriptionResponse;
}
- eventSubscriptionResponse.setStatus(HttpStatus.NO_CONTENT.value());
+ eventSubscriptionResponse.setStatus(HttpStatus.SC_NO_CONTENT);
return eventSubscriptionResponse;
} catch (OBEventNotificationException e) {
log.error("Error occurred while deleting event subscription", e);
- eventSubscriptionResponse.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
+ eventSubscriptionResponse.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
eventSubscriptionResponse.setErrorResponse(EventNotificationServiceUtil.getErrorDTO(
EventNotificationConstants.INVALID_REQUEST, e.getMessage()));
return eventSubscriptionResponse;
@@ -277,7 +277,7 @@ private EventSubscriptionResponse validateClientId(String clientId) {
} catch (OBEventNotificationException e) {
log.error("Invalid client ID", e);
EventSubscriptionResponse eventSubscriptionResponse = new EventSubscriptionResponse();
- eventSubscriptionResponse.setStatus(HttpStatus.BAD_REQUEST.value());
+ eventSubscriptionResponse.setStatus(HttpStatus.SC_BAD_REQUEST);
eventSubscriptionResponse.setErrorResponse(EventNotificationServiceUtil.getErrorDTO(
EventNotificationConstants.INVALID_REQUEST, e.getMessage()));
return eventSubscriptionResponse;
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/test/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/EventSubscriptionDAOImplTests.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/test/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/EventSubscriptionDAOImplTests.java
index 5579e440..00f5fe50 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/test/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/EventSubscriptionDAOImplTests.java
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/test/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/EventSubscriptionDAOImplTests.java
@@ -34,6 +34,7 @@
import org.testng.annotations.Test;
import java.sql.Connection;
+import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -50,6 +51,7 @@
public class EventSubscriptionDAOImplTests extends PowerMockTestCase {
private static Connection mockedConnection;
private PreparedStatement mockedPreparedStatement;
+ private DatabaseMetaData mockedDatabaseMetaData;
EventSubscriptionDAOImpl eventSubscriptionDAOImpl = new EventSubscriptionDAOImpl(
new EventSubscriptionSqlStatements());
@@ -58,6 +60,7 @@ public class EventSubscriptionDAOImplTests extends PowerMockTestCase {
public void mock() throws OBEventNotificationException {
mockedConnection = Mockito.mock(Connection.class);
mockedPreparedStatement = Mockito.mock(PreparedStatement.class);
+ mockedDatabaseMetaData = Mockito.mock(DatabaseMetaData.class);
PowerMockito.mockStatic(DatabaseUtil.class);
PowerMockito.when(DatabaseUtil.getDBConnection()).thenReturn(mockedConnection);
}
@@ -66,6 +69,10 @@ public void mock() throws OBEventNotificationException {
public void testStoreEventSubscription() throws OBEventNotificationException, SQLException {
when(mockedConnection.prepareStatement(anyString())).thenReturn(mockedPreparedStatement);
when(mockedPreparedStatement.executeUpdate()).thenReturn(1);
+
+ when(mockedConnection.getMetaData()).thenReturn(mockedDatabaseMetaData);
+ when(mockedDatabaseMetaData.getDriverName()).thenReturn("");
+
EventSubscription sampleEventSubscription = EventNotificationTestUtils.getSampleEventSubscription();
EventSubscription result = eventSubscriptionDAOImpl.storeEventSubscription(mockedConnection,
@@ -81,6 +88,9 @@ public void testStoreEventSubscriptionDBError() throws OBEventNotificationExcept
when(mockedConnection.prepareStatement(anyString())).thenReturn(mockedPreparedStatement);
when(mockedPreparedStatement.executeUpdate()).thenThrow(new SQLException());
+ when(mockedConnection.getMetaData()).thenReturn(mockedDatabaseMetaData);
+ when(mockedDatabaseMetaData.getDriverName()).thenReturn("");
+
eventSubscriptionDAOImpl.storeEventSubscription(mockedConnection,
EventNotificationTestUtils.getSampleEventSubscription());
}
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/util/EventSubscriptionUtils.java b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/util/EventSubscriptionUtils.java
index 6c8ac0f1..0b621b44 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/util/EventSubscriptionUtils.java
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/src/main/java/com/wso2/openbanking/accelerator/event/notifications/endpoint/util/EventSubscriptionUtils.java
@@ -29,7 +29,7 @@
import net.minidev.json.parser.JSONParser;
import net.minidev.json.parser.ParseException;
import org.apache.commons.io.IOUtils;
-import org.springframework.http.HttpStatus;
+import org.apache.http.HttpStatus;
import java.io.IOException;
@@ -76,7 +76,7 @@ public static JSONObject getJSONObjectPayload(HttpServletRequest request) throws
*/
public static Response mapEventSubscriptionServiceResponse(EventSubscriptionResponse eventSubscriptionResponse) {
int status = eventSubscriptionResponse.getStatus();
- if (HttpStatus.NO_CONTENT.value() == status) {
+ if (HttpStatus.SC_NO_CONTENT == status) {
return Response.status(status)
.build();
} else if (eventSubscriptionResponse.getErrorResponse() == null) {
@@ -85,7 +85,7 @@ public static Response mapEventSubscriptionServiceResponse(EventSubscriptionResp
.entity(eventSubscriptionResponse.getResponseBody())
.build();
} else {
- return Response.status(HttpStatus.INTERNAL_SERVER_ERROR.value())
+ return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
.entity(EventNotificationServiceUtil.getErrorDTO(EventNotificationConstants.INVALID_REQUEST,
EventNotificationConstants.ERROR_HANDLING_EVENT_SUBSCRIPTION))
.build();
From 5e08584ea9ca4275b06088d04a38d6703a309f98 Mon Sep 17 00:00:00 2001
From: Anju Chamantha
Date: Tue, 4 Jun 2024 16:07:11 +0530
Subject: [PATCH 202/281] Adding a separate class to handle Postgre Sql
EventSubscription
---
.../service/dao/EventSubscriptionDAOImpl.java | 8 +--
.../PostgreSqlEventSubscriptionDAOImpl.java | 68 +++++++++++++++++++
.../EventSubscriptionStoreInitializer.java | 3 +-
.../dao/EventSubscriptionDAOImplTests.java | 10 ---
4 files changed, 71 insertions(+), 18 deletions(-)
create mode 100644 open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/PostgreSqlEventSubscriptionDAOImpl.java
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/EventSubscriptionDAOImpl.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/EventSubscriptionDAOImpl.java
index cea47a18..7f86e8fa 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/EventSubscriptionDAOImpl.java
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/EventSubscriptionDAOImpl.java
@@ -60,19 +60,13 @@ public EventSubscription storeEventSubscription(Connection connection, EventSubs
final String sql = sqlStatements.storeEventSubscriptionQuery();
try (PreparedStatement storeEventSubscriptionStatement = connection.prepareStatement(sql)) {
- String driverName = connection.getMetaData().getDriverName();
storeEventSubscriptionStatement.setString(1, eventSubscription.getSubscriptionId());
storeEventSubscriptionStatement.setString(2, eventSubscription.getClientId());
storeEventSubscriptionStatement.setString(3, eventSubscription.getCallbackUrl());
storeEventSubscriptionStatement.setLong(4, eventSubscription.getTimeStamp());
storeEventSubscriptionStatement.setString(5, eventSubscription.getSpecVersion());
storeEventSubscriptionStatement.setString(6, eventSubscription.getStatus());
- if (driverName.contains(EventNotificationConstants.POSTGRE_SQL)) {
- storeEventSubscriptionStatement.setObject(7, eventSubscription.getRequestData(),
- java.sql.Types.OTHER);
- } else {
- storeEventSubscriptionStatement.setString(7, eventSubscription.getRequestData());
- }
+ storeEventSubscriptionStatement.setString(7, eventSubscription.getRequestData());
storeSubscriptionAffectedRows = storeEventSubscriptionStatement.executeUpdate();
if (storeSubscriptionAffectedRows == 0) {
log.error("Failed to store the event notification subscription.");
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/PostgreSqlEventSubscriptionDAOImpl.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/PostgreSqlEventSubscriptionDAOImpl.java
new file mode 100644
index 00000000..a448dbdc
--- /dev/null
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/PostgreSqlEventSubscriptionDAOImpl.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
+ *
+ * This software is the property of WSO2 LLC. and its suppliers, if any.
+ * Dissemination of any information or reproduction of any material contained
+ * herein in any form is strictly forbidden, unless permitted by WSO2 expressly.
+ * You may not alter or remove any copyright or other notice from copies of this content.
+ */
+
+package com.wso2.openbanking.accelerator.event.notifications.service.dao;
+
+import com.wso2.openbanking.accelerator.event.notifications.service.constants.EventNotificationConstants;
+import com.wso2.openbanking.accelerator.event.notifications.service.exceptions.OBEventNotificationException;
+import com.wso2.openbanking.accelerator.event.notifications.service.model.EventSubscription;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.time.Instant;
+import java.util.UUID;
+
+/**
+ * Postgres SQL EventSubscriptionDAO Impl.
+ */
+public class PostgreSqlEventSubscriptionDAOImpl extends EventSubscriptionDAOImpl {
+
+ private static final Log log = LogFactory.getLog(PostgreSqlEventSubscriptionDAOImpl.class);
+
+ public PostgreSqlEventSubscriptionDAOImpl(EventSubscriptionSqlStatements sqlStatements) {
+ super(sqlStatements);
+ }
+
+ @Override
+ public EventSubscription storeEventSubscription(Connection connection, EventSubscription eventSubscription)
+ throws OBEventNotificationException {
+
+ int storeSubscriptionAffectedRows;
+
+ UUID subscriptionId = UUID.randomUUID();
+ long unixTime = Instant.now().getEpochSecond();
+ eventSubscription.setSubscriptionId(subscriptionId.toString());
+ eventSubscription.setTimeStamp(unixTime);
+ eventSubscription.setStatus(EventNotificationConstants.CREATED);
+
+ final String sql = sqlStatements.storeEventSubscriptionQuery();
+ try (PreparedStatement storeEventSubscriptionStatement = connection.prepareStatement(sql)) {
+ storeEventSubscriptionStatement.setString(1, eventSubscription.getSubscriptionId());
+ storeEventSubscriptionStatement.setString(2, eventSubscription.getClientId());
+ storeEventSubscriptionStatement.setString(3, eventSubscription.getCallbackUrl());
+ storeEventSubscriptionStatement.setLong(4, eventSubscription.getTimeStamp());
+ storeEventSubscriptionStatement.setString(5, eventSubscription.getSpecVersion());
+ storeEventSubscriptionStatement.setString(6, eventSubscription.getStatus());
+ storeEventSubscriptionStatement.setObject(7, eventSubscription.getRequestData(),
+ java.sql.Types.OTHER);
+ storeSubscriptionAffectedRows = storeEventSubscriptionStatement.executeUpdate();
+ if (storeSubscriptionAffectedRows == 0) {
+ log.error("Failed to store the event notification subscription.");
+ throw new OBEventNotificationException(EventNotificationConstants.ERROR_STORING_EVENT_SUBSCRIPTION);
+ }
+ } catch (SQLException e) {
+ log.error("SQL exception when storing the event types of the subscription", e);
+ throw new OBEventNotificationException(EventNotificationConstants.ERROR_STORING_EVENT_SUBSCRIPTION);
+ }
+ return eventSubscription;
+ }
+}
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/persistence/EventSubscriptionStoreInitializer.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/persistence/EventSubscriptionStoreInitializer.java
index 3d0f63ad..a3d040bf 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/persistence/EventSubscriptionStoreInitializer.java
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/persistence/EventSubscriptionStoreInitializer.java
@@ -23,6 +23,7 @@
import com.wso2.openbanking.accelerator.event.notifications.service.dao.EventSubscriptionDAO;
import com.wso2.openbanking.accelerator.event.notifications.service.dao.EventSubscriptionDAOImpl;
import com.wso2.openbanking.accelerator.event.notifications.service.dao.EventSubscriptionSqlStatements;
+import com.wso2.openbanking.accelerator.event.notifications.service.dao.PostgreSqlEventSubscriptionDAOImpl;
import com.wso2.openbanking.accelerator.event.notifications.service.exceptions.OBEventNotificationException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -52,7 +53,7 @@ public static EventSubscriptionDAO initializeSubscriptionDAO() throws OBEventNot
if (driverName.contains(MYSQL) || driverName.contains(H2)) {
eventSubscriptionDao = new EventSubscriptionDAOImpl(new EventSubscriptionSqlStatements());
} else if (driverName.contains(POSTGRE)) {
- eventSubscriptionDao = new EventSubscriptionDAOImpl(new EventSubscriptionSqlStatements());
+ eventSubscriptionDao = new PostgreSqlEventSubscriptionDAOImpl(new EventSubscriptionSqlStatements());
} else if (driverName.contains(MSSQL)) {
eventSubscriptionDao = new EventSubscriptionDAOImpl(new EventSubscriptionSqlStatements());
} else if (driverName.contains(ORACLE)) {
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/test/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/EventSubscriptionDAOImplTests.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/test/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/EventSubscriptionDAOImplTests.java
index 00f5fe50..5579e440 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/test/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/EventSubscriptionDAOImplTests.java
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/test/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/EventSubscriptionDAOImplTests.java
@@ -34,7 +34,6 @@
import org.testng.annotations.Test;
import java.sql.Connection;
-import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -51,7 +50,6 @@
public class EventSubscriptionDAOImplTests extends PowerMockTestCase {
private static Connection mockedConnection;
private PreparedStatement mockedPreparedStatement;
- private DatabaseMetaData mockedDatabaseMetaData;
EventSubscriptionDAOImpl eventSubscriptionDAOImpl = new EventSubscriptionDAOImpl(
new EventSubscriptionSqlStatements());
@@ -60,7 +58,6 @@ public class EventSubscriptionDAOImplTests extends PowerMockTestCase {
public void mock() throws OBEventNotificationException {
mockedConnection = Mockito.mock(Connection.class);
mockedPreparedStatement = Mockito.mock(PreparedStatement.class);
- mockedDatabaseMetaData = Mockito.mock(DatabaseMetaData.class);
PowerMockito.mockStatic(DatabaseUtil.class);
PowerMockito.when(DatabaseUtil.getDBConnection()).thenReturn(mockedConnection);
}
@@ -69,10 +66,6 @@ public void mock() throws OBEventNotificationException {
public void testStoreEventSubscription() throws OBEventNotificationException, SQLException {
when(mockedConnection.prepareStatement(anyString())).thenReturn(mockedPreparedStatement);
when(mockedPreparedStatement.executeUpdate()).thenReturn(1);
-
- when(mockedConnection.getMetaData()).thenReturn(mockedDatabaseMetaData);
- when(mockedDatabaseMetaData.getDriverName()).thenReturn("");
-
EventSubscription sampleEventSubscription = EventNotificationTestUtils.getSampleEventSubscription();
EventSubscription result = eventSubscriptionDAOImpl.storeEventSubscription(mockedConnection,
@@ -88,9 +81,6 @@ public void testStoreEventSubscriptionDBError() throws OBEventNotificationExcept
when(mockedConnection.prepareStatement(anyString())).thenReturn(mockedPreparedStatement);
when(mockedPreparedStatement.executeUpdate()).thenThrow(new SQLException());
- when(mockedConnection.getMetaData()).thenReturn(mockedDatabaseMetaData);
- when(mockedDatabaseMetaData.getDriverName()).thenReturn("");
-
eventSubscriptionDAOImpl.storeEventSubscription(mockedConnection,
EventNotificationTestUtils.getSampleEventSubscription());
}
From 0fe7bbd49393761a4360249e00e4607ee6940982 Mon Sep 17 00:00:00 2001
From: Anju Chamantha
Date: Tue, 4 Jun 2024 16:39:16 +0530
Subject: [PATCH 203/281] Remove not used constant
---
.../service/constants/EventNotificationConstants.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/constants/EventNotificationConstants.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/constants/EventNotificationConstants.java
index e3e09261..835e2248 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/constants/EventNotificationConstants.java
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/constants/EventNotificationConstants.java
@@ -115,5 +115,4 @@ public class EventNotificationConstants {
public static final String EVENT_SUBSCRIPTIONS_NOT_FOUND = "Event subscriptions not found for the given client id.";
public static final String ERROR_HANDLING_EVENT_SUBSCRIPTION = "Error occurred while handling the event " +
"subscription request";
- public static final String POSTGRE_SQL = "PostgreSQL";
}
From b18a4b2a7590752bff54b42ccfd44ae638474986 Mon Sep 17 00:00:00 2001
From: Anju Chamantha
Date: Fri, 7 Jun 2024 09:41:12 +0530
Subject: [PATCH 204/281] Change licence header
---
.../PostgreSqlEventSubscriptionDAOImpl.java | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/PostgreSqlEventSubscriptionDAOImpl.java b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/PostgreSqlEventSubscriptionDAOImpl.java
index a448dbdc..7322ff8b 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/PostgreSqlEventSubscriptionDAOImpl.java
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/src/main/java/com/wso2/openbanking/accelerator/event/notifications/service/dao/PostgreSqlEventSubscriptionDAOImpl.java
@@ -1,10 +1,19 @@
/**
- * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
*
- * This software is the property of WSO2 LLC. and its suppliers, if any.
- * Dissemination of any information or reproduction of any material contained
- * herein in any form is strictly forbidden, unless permitted by WSO2 expressly.
- * You may not alter or remove any copyright or other notice from copies of this content.
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package com.wso2.openbanking.accelerator.event.notifications.service.dao;
From 3b48f700cad06fa921b5279e96d3703ac671ab2f Mon Sep 17 00:00:00 2001
From: WSO2 Builder
Date: Tue, 11 Jun 2024 03:39:30 +0000
Subject: [PATCH 205/281] [WSO2 Release] [Jenkins #286] [Release 3.2.6] prepare
release v3.2.6
---
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.common/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.data.publisher/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.gateway/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.identity/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.keymanager/pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.runtime/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.throttler.dao/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.consent.endpoint/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.demo.backend/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.authentication.webapp/pom.xml | 2 +-
open-banking-accelerator/pom.xml | 4 ++--
pom.xml | 4 ++--
react-apps/pom.xml | 2 +-
react-apps/self-care-portal/pom.xml | 2 +-
29 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml b/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml
index fec503e2..511d91e2 100644
--- a/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml
+++ b/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml
@@ -19,7 +19,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6-SNAPSHOT
+ 3.2.6../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
index e57703e7..1d68005c 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6-SNAPSHOT
+ 3.2.6../../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml
index d8c7e2d1..69abf782 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml
@@ -23,7 +23,7 @@
com.wso2.openbanking.accelerator.data.publishercom.wso2.openbanking.accelerator
- 3.2.6-SNAPSHOT
+ 3.2.6../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
index 1c4111b6..2d6757d3 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6-SNAPSHOT
+ 3.2.6../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml
index b2cf5657..d1b26a31 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6-SNAPSHOT
+ 3.2.6../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
index 0f16490c..dd16daff 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6-SNAPSHOT
+ 3.2.6../../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml
index 746f71f9..d39c3bc7 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6-SNAPSHOT
+ 3.2.6../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml
index 8473dbff..ab3d5b24 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml
@@ -18,7 +18,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6-SNAPSHOT
+ 3.2.6../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml
index f52d7b4c..fea36500 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml
@@ -20,7 +20,7 @@
com.wso2.openbanking.accelerator.runtimecom.wso2.openbanking.accelerator
- 3.2.6-SNAPSHOT
+ 3.2.6../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml
index da0c13d9..29291b85 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6-SNAPSHOT
+ 3.2.6../../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml
index 1c424048..519ef574 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6-SNAPSHOT
+ 3.2.6../../pom.xml
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml
index 9afb92fc..aa5a003d 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6-SNAPSHOT
+ 3.2.6../../../pom.xml
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
index 36ee8b35..bee63f08 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6-SNAPSHOT
+ 3.2.6../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml
index 809fcaba..a633eedf 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml
@@ -21,7 +21,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6-SNAPSHOT
+ 3.2.6../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml
index 0fa5af5c..13553fa7 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml
@@ -19,7 +19,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6-SNAPSHOT
+ 3.2.6../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml
index f873c567..092cdb8b 100644
--- a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml
+++ b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6-SNAPSHOT
+ 3.2.6../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml
index 4bd6535b..6486cac6 100644
--- a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml
+++ b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6-SNAPSHOT
+ 3.2.6../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml
index 9d521994..79313ced 100755
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml
@@ -21,7 +21,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6-SNAPSHOT
+ 3.2.6../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml
index f5b4ac6b..6f510450 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml
@@ -18,7 +18,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6-SNAPSHOT
+ 3.2.6../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml
index 35cb44a6..65cfdf7a 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6-SNAPSHOT
+ 3.2.6../../../pom.xml
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
index a6858d8d..9679f24a 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6-SNAPSHOT
+ 3.2.6../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml
index 0fd65679..f3480a03 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml
@@ -21,7 +21,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6-SNAPSHOT
+ 3.2.6../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml
index 436e487b..179484e3 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml
@@ -19,7 +19,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6-SNAPSHOT
+ 3.2.6../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml
index 412d8091..beed677d 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6-SNAPSHOT
+ 3.2.6../../../pom.xml
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml
index 033a0cd2..f805135d 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml
@@ -21,7 +21,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6-SNAPSHOT
+ 3.2.6../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/pom.xml b/open-banking-accelerator/pom.xml
index 006efbca..8d617857 100644
--- a/open-banking-accelerator/pom.xml
+++ b/open-banking-accelerator/pom.xml
@@ -23,14 +23,14 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.2.6-SNAPSHOT
+ 3.2.6../pom.xmlWSO2 Open Banking Acceleratoropen-banking-acceleratorpom
- 3.2.6-SNAPSHOT
+ 3.2.6components/com.wso2.openbanking.accelerator.common
diff --git a/pom.xml b/pom.xml
index 31f0e48d..cef287c9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,7 +21,7 @@
com.wso2.openbanking.acceleratoropen-bankingpom
- 3.2.6-SNAPSHOT
+ 3.2.6org.wso2
@@ -172,7 +172,7 @@
https://github.com/wso2/financial-open-banking.gitscm:git:https://github.com/wso2/financial-open-banking.gitscm:git:https://github.com/wso2/financial-open-banking.git
- HEAD
+ v3.2.6
diff --git a/react-apps/pom.xml b/react-apps/pom.xml
index 93850a09..dc51bec8 100644
--- a/react-apps/pom.xml
+++ b/react-apps/pom.xml
@@ -23,7 +23,7 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.2.6-SNAPSHOT
+ 3.2.6../pom.xml
diff --git a/react-apps/self-care-portal/pom.xml b/react-apps/self-care-portal/pom.xml
index eeb48be1..c856691f 100644
--- a/react-apps/self-care-portal/pom.xml
+++ b/react-apps/self-care-portal/pom.xml
@@ -23,7 +23,7 @@
com.wso2.openbanking.acceleratorreact-apps
- 3.2.6-SNAPSHOT
+ 3.2.6../pom.xml
From 57bb9fea3dd1c18dfa856fad1edf7b6603318f61 Mon Sep 17 00:00:00 2001
From: WSO2 Builder
Date: Tue, 11 Jun 2024 03:39:31 +0000
Subject: [PATCH 206/281] [WSO2 Release] [Jenkins #286] [Release 3.2.6] prepare
for next development iteration
---
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.common/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.data.publisher/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.gateway/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.identity/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.keymanager/pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.runtime/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.throttler.dao/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.consent.endpoint/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml | 2 +-
.../com.wso2.openbanking.accelerator.demo.backend/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../com.wso2.openbanking.authentication.webapp/pom.xml | 2 +-
open-banking-accelerator/pom.xml | 4 ++--
pom.xml | 4 ++--
react-apps/pom.xml | 2 +-
react-apps/self-care-portal/pom.xml | 2 +-
29 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml b/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml
index 511d91e2..b201b950 100644
--- a/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml
+++ b/open-banking-accelerator/components/account-metadata/com.wso2.openbanking.accelerator.account.metadata.service/pom.xml
@@ -19,7 +19,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6
+ 3.2.7-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
index 1d68005c..f0628ffe 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6
+ 3.2.7-SNAPSHOT../../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml
index 69abf782..d5efddbd 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.authentication.data.publisher/pom.xml
@@ -23,7 +23,7 @@
com.wso2.openbanking.accelerator.data.publishercom.wso2.openbanking.accelerator
- 3.2.6
+ 3.2.7-SNAPSHOT../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
index 2d6757d3..18055c5d 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/com.wso2.openbanking.accelerator.data.publisher.common/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6
+ 3.2.7-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml
index d1b26a31..7c6ef186 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.data.publisher/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6
+ 3.2.7-SNAPSHOT../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
index dd16daff..b1a2fee0 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.gateway/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6
+ 3.2.7-SNAPSHOT../../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml
index d39c3bc7..5dad318b 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.identity/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6
+ 3.2.7-SNAPSHOT../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml
index ab3d5b24..b474fc7d 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.keymanager/pom.xml
@@ -18,7 +18,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6
+ 3.2.7-SNAPSHOT../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml
index fea36500..29ab203f 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/com.wso2.openbanking.accelerator.runtime.identity.authn.filter/pom.xml
@@ -20,7 +20,7 @@
com.wso2.openbanking.accelerator.runtimecom.wso2.openbanking.accelerator
- 3.2.6
+ 3.2.7-SNAPSHOT../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml
index 29291b85..d29c96b4 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.runtime/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6
+ 3.2.7-SNAPSHOT../../pom.xml
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml
index 519ef574..144e86e4 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.service.activator/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6
+ 3.2.7-SNAPSHOT../../pom.xml
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml
index aa5a003d..a2b331a7 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/pom.xml
@@ -22,7 +22,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6
+ 3.2.7-SNAPSHOT../../../pom.xml
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
index bee63f08..dea98546 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.dao/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6
+ 3.2.7-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml
index a633eedf..0d6d6baa 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.mgt.service/pom.xml
@@ -21,7 +21,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6
+ 3.2.7-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml
index 13553fa7..15d770a4 100644
--- a/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml
+++ b/open-banking-accelerator/components/event-notifications/com.wso2.openbanking.accelerator.event.notifications.service/pom.xml
@@ -19,7 +19,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6
+ 3.2.7-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml
index 092cdb8b..aaa59b78 100644
--- a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml
+++ b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.dao/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6
+ 3.2.7-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml
index 6486cac6..8ebc25cb 100644
--- a/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml
+++ b/open-banking-accelerator/components/ob-throttler/com.wso2.openbanking.accelerator.throttler.service/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6
+ 3.2.7-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml
index 79313ced..c5429427 100755
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.application.info.endpoint/pom.xml
@@ -21,7 +21,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6
+ 3.2.7-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml
index 6f510450..0660cff8 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.ciba.authentication.endpoint/pom.xml
@@ -18,7 +18,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6
+ 3.2.7-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml
index 65cfdf7a..0389a94e 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.consent.endpoint/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6
+ 3.2.7-SNAPSHOT../../../pom.xml
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
index 9679f24a..c63777f6 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.dcr.endpoint/pom.xml
@@ -20,7 +20,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6
+ 3.2.7-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml
index f3480a03..542467b3 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/pom.xml
@@ -21,7 +21,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6
+ 3.2.7-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml
index 179484e3..35ad4afd 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.event.notifications.endpoint/pom.xml
@@ -19,7 +19,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6
+ 3.2.7-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml
index beed677d..24538fb3 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.push.authorization.endpoint/pom.xml
@@ -23,7 +23,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6
+ 3.2.7-SNAPSHOT../../../pom.xml
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml
index f805135d..94858efb 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.authentication.webapp/pom.xml
@@ -21,7 +21,7 @@
open-banking-acceleratorcom.wso2.openbanking.accelerator
- 3.2.6
+ 3.2.7-SNAPSHOT../../../pom.xml4.0.0
diff --git a/open-banking-accelerator/pom.xml b/open-banking-accelerator/pom.xml
index 8d617857..03599818 100644
--- a/open-banking-accelerator/pom.xml
+++ b/open-banking-accelerator/pom.xml
@@ -23,14 +23,14 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.2.6
+ 3.2.7-SNAPSHOT../pom.xmlWSO2 Open Banking Acceleratoropen-banking-acceleratorpom
- 3.2.6
+ 3.2.7-SNAPSHOTcomponents/com.wso2.openbanking.accelerator.common
diff --git a/pom.xml b/pom.xml
index cef287c9..3b515527 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,7 +21,7 @@
com.wso2.openbanking.acceleratoropen-bankingpom
- 3.2.6
+ 3.2.7-SNAPSHOTorg.wso2
@@ -172,7 +172,7 @@
https://github.com/wso2/financial-open-banking.gitscm:git:https://github.com/wso2/financial-open-banking.gitscm:git:https://github.com/wso2/financial-open-banking.git
- v3.2.6
+ HEAD
diff --git a/react-apps/pom.xml b/react-apps/pom.xml
index dc51bec8..7a18d041 100644
--- a/react-apps/pom.xml
+++ b/react-apps/pom.xml
@@ -23,7 +23,7 @@
com.wso2.openbanking.acceleratoropen-banking
- 3.2.6
+ 3.2.7-SNAPSHOT../pom.xml
diff --git a/react-apps/self-care-portal/pom.xml b/react-apps/self-care-portal/pom.xml
index c856691f..f4c56b74 100644
--- a/react-apps/self-care-portal/pom.xml
+++ b/react-apps/self-care-portal/pom.xml
@@ -23,7 +23,7 @@
com.wso2.openbanking.acceleratorreact-apps
- 3.2.6
+ 3.2.7-SNAPSHOT../pom.xml
From a6136322ebfae7e9520a2777af942788ec098b25 Mon Sep 17 00:00:00 2001
From: kalpana
Date: Wed, 19 Jun 2024 16:15:23 +0530
Subject: [PATCH 207/281] Resolving comments
---
.../common/util/ErrorConstants.java | 3 +-
.../impl/VRPSubmissionPayloadValidator.java | 150 ++++++++----------
.../validate/util/ConsentValidatorUtil.java | 15 +-
.../demo/backend/services/VrpService.java | 17 ++
4 files changed, 92 insertions(+), 93 deletions(-)
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java
index 4f29b3a1..f5085df2 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java
@@ -242,8 +242,7 @@ public class ErrorConstants {
public static final String PAYLOAD_FORMAT_ERROR_RISK = "Mandatory parameter Risk does not exists" +
" in the payload";
public static final String INVALID_PERIOD_TYPE = "Invalid value for period type in PeriodicLimits";
- public static final String INVALID_PARAMETER = "Parameter passed in is null , " +
- "empty or not a JSONObject";
+ public static final String INVALID_PARAMETER = "Parameter passed in is null ";
public static final String INVALID_CLIENT_ID_MATCH = "Consent validation failed due to client ID mismatch";
public static final String INVALID_DATE_TIME_FORMAT = "Date and Time is not in correct JSON " +
"ISO-8601 date-time format";
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/VRPSubmissionPayloadValidator.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/VRPSubmissionPayloadValidator.java
index fa22789d..a2b683cb 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/VRPSubmissionPayloadValidator.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/impl/VRPSubmissionPayloadValidator.java
@@ -44,10 +44,6 @@ public class VRPSubmissionPayloadValidator {
public static JSONObject validateInitiation(JSONObject initiationOfSubmission,
JSONObject initiationParameterOfConsentInitiation) {
- JSONObject validationResult = new JSONObject();
- validationResult.put(ConsentExtensionConstants.IS_VALID_PAYLOAD, false);
- validationResult.put(ConsentExtensionConstants.ERROR_CODE, "");
- validationResult.put(ConsentExtensionConstants.ERROR_MESSAGE, "");
if (initiationOfSubmission != null && initiationParameterOfConsentInitiation != null) {
@@ -88,6 +84,8 @@ public static JSONObject validateInitiation(JSONObject initiationOfSubmission,
}
//Validate Debtor Account
+ // This code if condition checks whether the debtor account parameter is present in both the request
+ // payloads (Initiation and the submission payloads) since both the payloads as to be equal.
if ((!initiationOfSubmission.containsKey(ConsentExtensionConstants.DEBTOR_ACC) &&
initiationParameterOfConsentInitiation.containsKey(ConsentExtensionConstants.DEBTOR_ACC)) ||
(initiationOfSubmission.containsKey(ConsentExtensionConstants.DEBTOR_ACC) &&
@@ -121,12 +119,8 @@ public static JSONObject validateInitiation(JSONObject initiationOfSubmission,
return ConsentValidatorUtil.getValidationResult(ErrorConstants.FIELD_INVALID,
ErrorConstants.DEBTOR_ACC_NOT_JSON_ERROR);
}
- } else {
- return ConsentValidatorUtil.getValidationResult(ErrorConstants.FIELD_MISSING,
- ErrorConstants.DEBTOR_ACC_NOT_FOUND);
}
-
if ((!initiationOfSubmission.containsKey(ConsentExtensionConstants.REMITTANCE_INFO)
&& initiationParameterOfConsentInitiation.containsKey(ConsentExtensionConstants.REMITTANCE_INFO)) ||
(initiationOfSubmission.containsKey(ConsentExtensionConstants.REMITTANCE_INFO)
@@ -150,23 +144,23 @@ public static JSONObject validateInitiation(JSONObject initiationOfSubmission,
JSONObject remittanceInformationInit = (JSONObject) initiationParameterOfConsentInitiation
.get(ConsentExtensionConstants.REMITTANCE_INFO);
- validationResult = VRPSubmissionPayloadValidator.validateRemittanceInfo
+ JSONObject validateRemittanceInfoResult = VRPSubmissionPayloadValidator.validateRemittanceInfo
(remittanceInformationSub, remittanceInformationInit);
- if (!Boolean.parseBoolean(validationResult.
+ if (!Boolean.parseBoolean(validateRemittanceInfoResult.
getAsString(ConsentExtensionConstants.IS_VALID_PAYLOAD))) {
- return validationResult;
+ return validateRemittanceInfoResult;
}
} else {
return ConsentValidatorUtil.getValidationResult(ErrorConstants.FIELD_INVALID,
ErrorConstants.INITIATION_REMITTANCE_INFO_NOT_JSON_ERROR);
}
-
- } else {
- return ConsentValidatorUtil.getValidationResult(ErrorConstants.FIELD_MISSING,
- ErrorConstants.INITIATION_REMITTANCE_INFO_PARAMETER_NOT_FOUND);
- }
+ }
+ } else {
+ return ConsentValidatorUtil.getValidationResult(ErrorConstants.FIELD_MISSING,
+ ErrorConstants.INVALID_PARAMETER);
}
+ JSONObject validationResult = new JSONObject();
validationResult.put(ConsentExtensionConstants.IS_VALID_PAYLOAD, true);
return validationResult;
}
@@ -185,12 +179,44 @@ public static JSONObject validateInstruction(JSONObject submission,
JSONObject initiation) {
JSONObject validationResult = new JSONObject();
- validationResult.put(ConsentExtensionConstants.IS_VALID_PAYLOAD, false);
- validationResult.put(ConsentExtensionConstants.ERROR_CODE, "");
- validationResult.put(ConsentExtensionConstants.ERROR_MESSAGE, "");
if (submission != null && initiation != null) {
+ if (!submission.containsKey(ConsentExtensionConstants.INSTRUCTED_AMOUNT)) {
+ return ConsentValidatorUtil.getValidationResult(ErrorConstants.FIELD_MISSING,
+ ErrorConstants.INSTRUCTED_AMOUNT_NOT_FOUND);
+ } else {
+ Object instructedAmountObject = submission.get(ConsentExtensionConstants.INSTRUCTED_AMOUNT);
+
+ if (isValidJSONObject(instructedAmountObject)) {
+ JSONObject instructedAmount = (JSONObject) instructedAmountObject;
+ if (!instructedAmount.containsKey(ConsentExtensionConstants.AMOUNT)) {
+ return ConsentValidatorUtil.getValidationResult(ErrorConstants.FIELD_MISSING,
+ ErrorConstants.INSTRUCTED_AMOUNT_AMOUNT_NOT_FOUND);
+ } else {
+ Object amountValue = instructedAmount.get(ConsentExtensionConstants.AMOUNT);
+ if (!isValidString(amountValue)) {
+ return ConsentValidatorUtil.getValidationResult(ErrorConstants.FIELD_INVALID,
+ ErrorConstants.INSTRUCTED_AMOUNT_NOT_STRING);
+ }
+
+ if (!instructedAmount.containsKey(ConsentExtensionConstants.CURRENCY)) {
+ return ConsentValidatorUtil.getValidationResult(ErrorConstants.FIELD_MISSING,
+ ErrorConstants.INSTRUCTED_AMOUNT_CURRENCY_NOT_FOUND);
+ } else {
+ Object currencyValue = instructedAmount.get(ConsentExtensionConstants.CURRENCY);
+ if (!isValidString(currencyValue)) {
+ return ConsentValidatorUtil.getValidationResult(ErrorConstants.FIELD_INVALID,
+ ErrorConstants.INSTRUCTED_AMOUNT_CURRENCY_NOT_STRING);
+ }
+ }
+ }
+ } else {
+ return ConsentValidatorUtil.getValidationResult(ErrorConstants.FIELD_INVALID,
+ ErrorConstants.INSTRUCTED_AMOUNT_NOT_JSON_ERROR);
+ }
+ }
+
if (submission.containsKey(ConsentExtensionConstants.INSTRUCTION_IDENTIFICATION)) {
Object value = submission.get(ConsentExtensionConstants.INSTRUCTION_IDENTIFICATION);
@@ -218,8 +244,8 @@ public static JSONObject validateInstruction(JSONObject submission,
//Validate Creditor Account
if (submission.containsKey(ConsentExtensionConstants.CREDITOR_ACC)) {
- //If the CreditorAccount was not specified in the the consent,
- // the CreditorAccount must be specified in the instruction
+ // If the CreditorAccount was not specified in the consent,the CreditorAccount must be specified
+ // in the instruction
if (!initiation.containsKey(ConsentExtensionConstants.CREDITOR_ACC)) {
validationResult.put(ConsentExtensionConstants.IS_VALID_PAYLOAD, true);
} else {
@@ -249,47 +275,10 @@ public static JSONObject validateInstruction(JSONObject submission,
ErrorConstants.CREDITOR_ACC_NOT_FOUND);
}
- if (submission.containsKey(ConsentExtensionConstants.INSTRUCTED_AMOUNT)) {
- Object instructedAmountObject = submission.get(ConsentExtensionConstants.INSTRUCTED_AMOUNT);
-
- if (isValidJSONObject(instructedAmountObject)) {
- JSONObject instructedAmount = (JSONObject) instructedAmountObject;
- if (!instructedAmount.containsKey(ConsentExtensionConstants.AMOUNT)) {
- return ConsentValidatorUtil.getValidationResult(ErrorConstants.FIELD_MISSING,
- ErrorConstants.INSTRUCTED_AMOUNT_AMOUNT_NOT_FOUND);
- } else {
- Object amountValue = instructedAmount.get(ConsentExtensionConstants.AMOUNT);
- if (!isValidString(amountValue)) {
- return ConsentValidatorUtil.getValidationResult(ErrorConstants.FIELD_INVALID,
- ErrorConstants.INSTRUCTED_AMOUNT_NOT_STRING);
- }
-
- if (!instructedAmount.containsKey(ConsentExtensionConstants.CURRENCY)) {
- return ConsentValidatorUtil.getValidationResult(ErrorConstants.FIELD_MISSING,
- ErrorConstants.INSTRUCTED_AMOUNT_CURRENCY_NOT_FOUND);
- } else {
- Object currencyValue = instructedAmount.get(ConsentExtensionConstants.CURRENCY);
- if (!isValidString(currencyValue)) {
- return ConsentValidatorUtil.getValidationResult(ErrorConstants.FIELD_INVALID,
- ErrorConstants.INSTRUCTED_AMOUNT_CURRENCY_NOT_STRING);
- }
- }
- }
- } else {
- return ConsentValidatorUtil.getValidationResult(ErrorConstants.FIELD_INVALID,
- ErrorConstants.INSTRUCTED_AMOUNT_NOT_JSON_ERROR);
- }
- } else {
- return ConsentValidatorUtil.getValidationResult(ErrorConstants.FIELD_MISSING,
- ErrorConstants.INSTRUCTED_AMOUNT_NOT_FOUND);
- }
-
-
if ((!submission.containsKey(ConsentExtensionConstants.REMITTANCE_INFO)
&& initiation.containsKey(ConsentExtensionConstants.REMITTANCE_INFO)) ||
(submission.containsKey(ConsentExtensionConstants.REMITTANCE_INFO)
- && !initiation.
- containsKey(ConsentExtensionConstants.REMITTANCE_INFO))) {
+ && !initiation.containsKey(ConsentExtensionConstants.REMITTANCE_INFO))) {
return ConsentValidatorUtil.getValidationResult(ErrorConstants.FIELD_MISSING,
ErrorConstants.REMITTANCE_INFO_NOT_FOUND);
} else if (submission.containsKey(ConsentExtensionConstants.REMITTANCE_INFO)
@@ -316,11 +305,12 @@ public static JSONObject validateInstruction(JSONObject submission,
return ConsentValidatorUtil.getValidationResult(ErrorConstants.FIELD_INVALID,
ErrorConstants.INSTRUCTION_REMITTANCE_INFO_NOT_JSON_ERROR);
}
- } else {
- return ConsentValidatorUtil.getValidationResult(ErrorConstants.FIELD_MISSING,
- ErrorConstants.INITIATION_REMITTANCE_INFO_PARAMETER_NOT_FOUND);
}
+ } else {
+ return ConsentValidatorUtil.getValidationResult(ErrorConstants.FIELD_MISSING,
+ ErrorConstants.INVALID_PARAMETER);
}
+
validationResult.put(ConsentExtensionConstants.IS_VALID_PAYLOAD, true);
return validationResult;
}
@@ -337,9 +327,6 @@ public static JSONObject validateInstruction(JSONObject submission,
public static JSONObject validateRemittanceInfo(JSONObject remittanceInformationSub,
JSONObject remittanceInformationInit) {
- JSONObject validationResult = new JSONObject();
- validationResult.put(ConsentExtensionConstants.IS_VALID_PAYLOAD, true);
-
if (!ConsentValidatorUtil.compareOptionalParameter(
remittanceInformationSub.getAsString(ConsentExtensionConstants.REFERENCE),
remittanceInformationInit.getAsString(ConsentExtensionConstants.REFERENCE))) {
@@ -355,6 +342,9 @@ public static JSONObject validateRemittanceInfo(JSONObject remittanceInformation
return ConsentValidatorUtil.getValidationResult(ErrorConstants.RESOURCE_CONSENT_MISMATCH,
ErrorConstants.REMITTANCE_UNSTRUCTURED_MISMATCH);
}
+
+ JSONObject validationResult = new JSONObject();
+ validationResult.put(ConsentExtensionConstants.IS_VALID_PAYLOAD, true);
return validationResult;
}
@@ -370,9 +360,6 @@ public static JSONObject validateRemittanceInfo(JSONObject remittanceInformation
public static JSONObject validateRisk(JSONObject riskOfSubmission,
JSONObject riskOfInitiation) {
- JSONObject validationResult = new JSONObject();
- validationResult.put(ConsentExtensionConstants.IS_VALID_PAYLOAD, true);
-
if (!ConsentValidatorUtil.compareOptionalParameter(
riskOfSubmission.getAsString(ConsentExtensionConstants.CONTEXT_CODE),
riskOfInitiation.getAsString(ConsentExtensionConstants.CONTEXT_CODE))) {
@@ -381,6 +368,8 @@ public static JSONObject validateRisk(JSONObject riskOfSubmission,
ErrorConstants.RISK_PARAMETER_MISMATCH);
}
+ JSONObject validationResult = new JSONObject();
+ validationResult.put(ConsentExtensionConstants.IS_VALID_PAYLOAD, true);
return validationResult;
}
@@ -390,13 +379,10 @@ public static JSONObject validateRisk(JSONObject riskOfSubmission,
* instance of JSONObject.
*
* @param submissionJson
- * @return
+ * @return validationResult
*/
public static JSONObject validateRiskParameter(JSONObject submissionJson) {
- JSONObject validationResult = new JSONObject();
- validationResult.put(ConsentExtensionConstants.IS_VALID_PAYLOAD, true);
-
//Validate RISK
if (submissionJson.containsKey(ConsentExtensionConstants.RISK)) {
@@ -411,6 +397,9 @@ public static JSONObject validateRiskParameter(JSONObject submissionJson) {
return ConsentValidatorUtil.getValidationResult(ErrorConstants.FIELD_MISSING,
ErrorConstants.RISK_NOT_FOUND);
}
+
+ JSONObject validationResult = new JSONObject();
+ validationResult.put(ConsentExtensionConstants.IS_VALID_PAYLOAD, true);
return validationResult;
}
@@ -431,8 +420,6 @@ public static boolean isValidString(Object value) {
* @return A JSONObject indicating the validation result.
*/
public static JSONObject validateInitiationParameter(JSONObject submissionData) {
- JSONObject validationResult = new JSONObject();
- validationResult.put(ConsentExtensionConstants.IS_VALID_PAYLOAD, true);
if (submissionData.containsKey(ConsentExtensionConstants.INITIATION)) {
@@ -448,6 +435,8 @@ public static JSONObject validateInitiationParameter(JSONObject submissionData)
ErrorConstants.INITIATION_NOT_FOUND);
}
+ JSONObject validationResult = new JSONObject();
+ validationResult.put(ConsentExtensionConstants.IS_VALID_PAYLOAD, true);
return validationResult;
}
@@ -458,8 +447,6 @@ public static JSONObject validateInitiationParameter(JSONObject submissionData)
* @return A JSONObject indicating the validation result.
*/
public static JSONObject validateInstructionParameter(JSONObject submissionData) {
- JSONObject validationResult = new JSONObject();
- validationResult.put(ConsentExtensionConstants.IS_VALID_PAYLOAD, true);
if (submissionData.containsKey(ConsentExtensionConstants.INSTRUCTION)) {
@@ -474,6 +461,8 @@ public static JSONObject validateInstructionParameter(JSONObject submissionData)
ErrorConstants.INSTRUCTION_NOT_FOUND);
}
+ JSONObject validationResult = new JSONObject();
+ validationResult.put(ConsentExtensionConstants.IS_VALID_PAYLOAD, true);
return validationResult;
}
@@ -484,10 +473,6 @@ public static JSONObject validateInstructionParameter(JSONObject submissionData)
* @return A JSONObject indicating the validation result.
*/
public static JSONObject validateSubmissionData(JSONObject submissionJson) {
- JSONObject validationResult = new JSONObject();
- validationResult.put(ConsentExtensionConstants.IS_VALID_PAYLOAD, true);
- validationResult.put(ConsentExtensionConstants.ERROR_CODE, "");
- validationResult.put(ConsentExtensionConstants.ERROR_MESSAGE, "");
if (!submissionJson.containsKey(ConsentExtensionConstants.DATA) &&
!(submissionJson.get(ConsentExtensionConstants.DATA) instanceof JSONObject)) {
@@ -495,6 +480,9 @@ public static JSONObject validateSubmissionData(JSONObject submissionJson) {
return ConsentValidatorUtil.getValidationResult(ErrorConstants.FIELD_MISSING,
ErrorConstants.DATA_NOT_FOUND);
}
+
+ JSONObject validationResult = new JSONObject();
+ validationResult.put(ConsentExtensionConstants.IS_VALID_PAYLOAD, true);
return validationResult;
}
@@ -508,5 +496,7 @@ public static boolean isValidJSONObject(Object value) {
return value instanceof JSONObject;
}
+
+
}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/util/ConsentValidatorUtil.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/util/ConsentValidatorUtil.java
index 5558f2e6..a80d3ba6 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/util/ConsentValidatorUtil.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/validate/util/ConsentValidatorUtil.java
@@ -74,30 +74,23 @@ public static JSONObject getValidationResult(String errorCode, String errorMessa
/**
- * Populates the provided consent validation result object with error information and constructs a JSON object
- * indicating an invalid payload.
+ * Populates the provided consent validation result object with error information.
*
* @param errorResult the JSONObject containing error details, specifically error message and error code
* @param consentValidationResult the ConsentValidationResult object to be updated with error details
- * @return validationResult
+ *
*/
- public static JSONObject setErrorMessageForConsentValidationResult(JSONObject errorResult
+ public static void setErrorMessageForConsentValidationResult(JSONObject errorResult
, ConsentValidationResult consentValidationResult) {
- JSONObject validationResult = new JSONObject();
- validationResult.put(ConsentExtensionConstants.IS_VALID_PAYLOAD, false);
- validationResult.put(ConsentExtensionConstants.ERROR_CODE, "");
- validationResult.put(ConsentExtensionConstants.ERROR_MESSAGE, "");
-
String errorMessage = errorResult.getAsString(ConsentExtensionConstants.ERROR_MESSAGE);
String errorCode = errorResult.getAsString(ConsentExtensionConstants.ERROR_CODE);
consentValidationResult.setErrorMessage(errorMessage);
consentValidationResult.setErrorCode(errorCode);
consentValidationResult.setHttpCode(HttpStatus.SC_BAD_REQUEST);
-
- return validationResult;
}
+
/**
* Method to construct the success validation result.
*
diff --git a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/src/main/java/com/wso2/openbanking/accelerator/demo/backend/services/VrpService.java b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/src/main/java/com/wso2/openbanking/accelerator/demo/backend/services/VrpService.java
index 16af1d38..14ce852c 100644
--- a/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/src/main/java/com/wso2/openbanking/accelerator/demo/backend/services/VrpService.java
+++ b/open-banking-accelerator/internal-apis/internal-webapps/com.wso2.openbanking.accelerator.demo.backend/src/main/java/com/wso2/openbanking/accelerator/demo/backend/services/VrpService.java
@@ -1,3 +1,20 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
:
<> >
))}
diff --git a/react-apps/self-care-portal/self-care-portal-frontend/accelerator/src/detailedAgreementPage/SharingDetails.jsx b/react-apps/self-care-portal/self-care-portal-frontend/accelerator/src/detailedAgreementPage/SharingDetails.jsx
index 64d0baff..7b74f662 100644
--- a/react-apps/self-care-portal/self-care-portal-frontend/accelerator/src/detailedAgreementPage/SharingDetails.jsx
+++ b/react-apps/self-care-portal/self-care-portal-frontend/accelerator/src/detailedAgreementPage/SharingDetails.jsx
@@ -1,19 +1,10 @@
-/**
- * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
+/*
+ * Copyright (c) 2021-2023, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
*
- * WSO2 LLC. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * This software is the property of WSO2 LLC. and its suppliers, if any.
+ * Dissemination of any information or reproduction of any material contained
+ * herein in any form is strictly forbidden, unless permitted by WSO2 expressly.
+ * You may not alter or remove any copyright or other notice from copies of this content.
*/
import React from 'react'
@@ -28,7 +19,6 @@ export const SharingDetails = ({consent, infoLabels, consentType}) => {
+
+ >
+ );
+}
diff --git a/react-apps/self-care-portal/src/main/java/com/wso2/openbanking/scp/webapp/servlet/OAuthCallbackServlet.java b/react-apps/self-care-portal/src/main/java/com/wso2/openbanking/scp/webapp/servlet/OAuthCallbackServlet.java
index 08560d08..eb8c5ed4 100644
--- a/react-apps/self-care-portal/src/main/java/com/wso2/openbanking/scp/webapp/servlet/OAuthCallbackServlet.java
+++ b/react-apps/self-care-portal/src/main/java/com/wso2/openbanking/scp/webapp/servlet/OAuthCallbackServlet.java
@@ -53,10 +53,13 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
try {
final String code = req.getParameter(CODE);
+ String redirectUrl = iamBaseUrl + "/consentmgr";
+
OAuthService oAuthService = OAuthService.getInstance();
if (StringUtils.isEmpty(code)) {
LOG.debug("Logout callback request received. Invalidating cookies.");
oAuthService.removeAllCookiesFromRequest(req, resp);
+ redirectUrl += "/logout";
} else {
LOG.debug("Authorization callback request received");
final String clientKey = Utils.getParameter(Constants.CONFIGURED_CLIENT_ID);
@@ -67,8 +70,6 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
// add cookies to response
oAuthService.generateCookiesFromTokens(tokenResponse, req, resp);
}
-
- final String redirectUrl = iamBaseUrl + "/consentmgr";
LOG.debug("Redirecting to frontend application: " + redirectUrl);
resp.sendRedirect(redirectUrl);
} catch (TokenGenerationException | IOException e) {
From 004a5ca83ad840bd4de504be1a4270375aa4ecd4 Mon Sep 17 00:00:00 2001
From: Sandaru Vithanage
Date: Fri, 28 Jun 2024 20:18:40 +0530
Subject: [PATCH 229/281] [OB3] [Accelerator] Saving Multiple Control
Parameters in Variable Recurring Payment Consent Initiation Payload (#74)
Adds Fixes in VRP Submission Flow
---
.../dbscripts/open-banking/consent/mssql.sql | 2 +-
.../dbscripts/open-banking/consent/mysql.sql | 2 +-
.../dbscripts/open-banking/consent/oracle.sql | 2 +-
.../open-banking/consent/postgresql.sql | 2 +-
.../common/util/ErrorConstants.java | 10 +
.../common/ConsentExtensionConstants.java | 5 +
.../event/executors/VRPEventExecutor.java | 119 ++++++++++
.../manage/impl/VRPConsentRequestHandler.java | 220 +++++++++++++-----
.../manage/model/PeriodicLimit.java | 202 ++++++++++++++++
.../validator/VRPConsentRequestValidator.java | 57 ++++-
.../extensions/util/PeriodicTypesEnum.java | 76 ++++++
.../impl/VRPSubmissionPayloadValidator.java | 17 +-
.../src/test/resources/dbScripts/h2.sql | 2 +-
13 files changed, 642 insertions(+), 74 deletions(-)
create mode 100644 open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/event/executors/VRPEventExecutor.java
create mode 100644 open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/model/PeriodicLimit.java
create mode 100644 open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/util/PeriodicTypesEnum.java
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/consent/mssql.sql b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/consent/mssql.sql
index a3fe7d61..6a9e59ad 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/consent/mssql.sql
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/consent/mssql.sql
@@ -78,7 +78,7 @@ CREATE TABLE OB_CONSENT_FILE (
CREATE TABLE OB_CONSENT_ATTRIBUTE (
CONSENT_ID VARCHAR(255) NOT NULL,
ATT_KEY VARCHAR(255) NOT NULL,
- ATT_VALUE VARCHAR(255) NOT NULL,
+ ATT_VALUE VARCHAR(1023) NOT NULL,
PRIMARY KEY(CONSENT_ID, ATT_KEY),
CONSTRAINT FK_OB_CONSENT_ATTRIBUTE FOREIGN KEY (CONSENT_ID) REFERENCES OB_CONSENT (CONSENT_ID) ON DELETE CASCADE
);
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/consent/mysql.sql b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/consent/mysql.sql
index 56d96860..f6cda887 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/consent/mysql.sql
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/consent/mysql.sql
@@ -82,7 +82,7 @@ ENGINE INNODB;
CREATE TABLE IF NOT EXISTS OB_CONSENT_ATTRIBUTE (
CONSENT_ID VARCHAR(255) NOT NULL,
ATT_KEY VARCHAR(255) NOT NULL,
- ATT_VALUE VARCHAR(255) NOT NULL,
+ ATT_VALUE VARCHAR(1023) NOT NULL,
PRIMARY KEY(CONSENT_ID, ATT_KEY),
CONSTRAINT FK_OB_CONSENT_ATTRIBUTE FOREIGN KEY (CONSENT_ID) REFERENCES OB_CONSENT (CONSENT_ID) ON DELETE CASCADE
)
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/consent/oracle.sql b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/consent/oracle.sql
index 267c39ff..743a5c49 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/consent/oracle.sql
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/consent/oracle.sql
@@ -77,7 +77,7 @@ CREATE TABLE OB_CONSENT_FILE (
CREATE TABLE OB_CONSENT_ATTRIBUTE (
CONSENT_ID VARCHAR(255) NOT NULL,
ATT_KEY VARCHAR(255) NOT NULL,
- ATT_VALUE VARCHAR(255) NOT NULL,
+ ATT_VALUE VARCHAR(1023) NOT NULL,
PRIMARY KEY(CONSENT_ID, ATT_KEY),
CONSTRAINT FK_OB_CONSENT_ATTRIBUTE FOREIGN KEY (CONSENT_ID) REFERENCES OB_CONSENT (CONSENT_ID) ON DELETE CASCADE
);
diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/consent/postgresql.sql b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/consent/postgresql.sql
index 1be43568..fa1147b4 100644
--- a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/consent/postgresql.sql
+++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/consent/postgresql.sql
@@ -75,7 +75,7 @@ CREATE TABLE IF NOT EXISTS OB_CONSENT_FILE (
CREATE TABLE IF NOT EXISTS OB_CONSENT_ATTRIBUTE (
CONSENT_ID VARCHAR(255) NOT NULL,
ATT_KEY VARCHAR(255) NOT NULL,
- ATT_VALUE VARCHAR(255) NOT NULL,
+ ATT_VALUE VARCHAR(1023) NOT NULL,
PRIMARY KEY(CONSENT_ID, ATT_KEY),
CONSTRAINT FK_OB_CONSENT_ATTRIBUTE FOREIGN KEY (CONSENT_ID) REFERENCES OB_CONSENT (CONSENT_ID) ON DELETE CASCADE
);
diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java
index cffb5a01..81106f21 100644
--- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java
+++ b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/util/ErrorConstants.java
@@ -220,6 +220,8 @@ public class ErrorConstants {
public static final String CONSENT_ID_NOT_FOUND = "Consent ID not available in consent data";
public static final String FIELD_INVALID_DATE = "OB.Field.InvalidDate";
public static final String EXPIRED_DATE_ERROR = "The ExpirationDateTime value has to be a future date.";
+ public static final String CONSENT_ATTRIBUTE_RETRIEVAL_ERROR = "Error occurred while retrieving the consent " +
+ "attributes";
// VRP error constants
@@ -263,6 +265,14 @@ public class ErrorConstants {
public static final String INVALID_PERIOD_ALIGNMENT = "Invalid value for period alignment in PeriodicLimits";
public static final String INVALID_PARAMETER_MESSAGE = "Parameter '%s' passed in is null, empty, or not a %s";
public static final String DATE_INVALID_PARAMETER_MESSAGE = "Invalid date-time range for ValidToDateTime ";
+ public static final String INVALID_PERIODIC_LIMIT_SIZE = "Periodic limits exceed the allowed limits";
+ public static final String DUPLICATE_PERIOD_TYPE = "Duplicate Period Types found in the request";
+ public static final String CURRENCY_MISMATCH = "Currency does not match with the currency of the periodic limits";
+ public static final int MAXIMUM_PERIODIC_LIMITS = 6;
+ public static final String INVALID_MAXIMUM_INDIVIDUAL_CURRENCY = "Invalid value for Currency in " +
+ "MaximumIndividualAmount";
+ public static final String INVALID_PERIODIC_LIMIT_AMOUNT = "Invalid value for in Amount in Periodic Limits";
+ public static final String INVALID_PERIODIC_LIMIT_CURRENCY = "Invalid value for Currency in Periodic Limits";
// vrp path parameters
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/ConsentExtensionConstants.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/ConsentExtensionConstants.java
index 1d54e4a4..4062a1bf 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/ConsentExtensionConstants.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/ConsentExtensionConstants.java
@@ -174,8 +174,11 @@ public class ConsentExtensionConstants {
public static final String MAXIMUM_INDIVIDUAL_AMOUNT = "MaximumIndividualAmount";
public static final String MAXIMUM_INDIVIDUAL_AMOUNT_CURRENCY = "MaximumIndividualAmount.Amount.Currency";
public static final String PERIODIC_LIMITS = "PeriodicLimits";
+ public static final String PERIODIC_TYPES = "PeriodicTypes";
public static final String PERIOD_AMOUNT_LIMIT = "Amount";
public static final String PERIOD_LIMIT_CURRENCY = "PeriodicLimits.Currency";
+ public static final String CYCLIC_EXPIRY_TIME = "cyclicExpiryTime";
+ public static final String CYCLIC_REMAINING_AMOUNT = "cyclicRemainingAmount";
//vrp period alignment
public static final String PERIOD_ALIGNMENT = "PeriodAlignment";
@@ -219,4 +222,6 @@ public class ConsentExtensionConstants {
public static final String VRP_PATH = "/domestic-vrps";
public static final String PREVIOUS_PAID_AMOUNT = "prevPaidAmount";
public static final String PREVIOUS_LAST_PAYMENT_DATE = "prevLastPaymentDate";
+
+
}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/event/executors/VRPEventExecutor.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/event/executors/VRPEventExecutor.java
new file mode 100644
index 00000000..126ad48a
--- /dev/null
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/event/executors/VRPEventExecutor.java
@@ -0,0 +1,119 @@
+/**
+ * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.wso2.openbanking.accelerator.consent.extensions.event.executors;
+
+import com.wso2.openbanking.accelerator.common.event.executor.OBEventExecutor;
+import com.wso2.openbanking.accelerator.common.event.executor.model.OBEvent;
+import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentExtensionConstants;
+import com.wso2.openbanking.accelerator.consent.extensions.manage.model.PeriodicLimit;
+import net.minidev.json.JSONArray;
+import net.minidev.json.JSONObject;
+import net.minidev.json.parser.JSONParser;
+import net.minidev.json.parser.ParseException;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This class is responsible for executing Variable Recurring Payments (VRP) events.
+ * It implements the OBEventExecutor interface and overrides its methods to provide
+ * specific implementations for VRP events.
+ */
+public class VRPEventExecutor implements OBEventExecutor {
+
+ public static List validateInstructedAmountWithControlParameters(BigDecimal instructedAmount,
+ JSONObject controlParameters) {
+
+ /**
+ * Validates the instructed amount with control parameters and returns a list of PeriodicLimit objects.
+ * If the instructed amount is greater than the maximum individual amount or the cyclic remaining amount,
+ * an empty list is returned. If the JSON parsing fails, an empty list is also returned.
+ *
+ * @param instructedAmount The instructed amount to be validated
+ * @param controlParameters The control parameters to be used for validation
+ * @return A list of PeriodicLimit objects
+ */
+ List periodicLimitsList = new ArrayList<>();
+
+ BigDecimal maxIndividualAmount = BigDecimal.valueOf(Double.parseDouble(controlParameters.
+ getAsString(ConsentExtensionConstants.MAXIMUM_INDIVIDUAL_AMOUNT)));
+
+ if (instructedAmount.compareTo(maxIndividualAmount) > 0) {
+ return periodicLimitsList;
+ }
+
+ JSONParser parser = new JSONParser(JSONParser.MODE_JSON_SIMPLE);
+ JSONArray periodicLimits;
+
+ try {
+ periodicLimits = (JSONArray) parser.parse(controlParameters.
+ getAsString(ConsentExtensionConstants.PERIODIC_LIMITS));
+ } catch (ParseException e) {
+ // Log the error or handle it as needed
+ return periodicLimitsList;
+ }
+
+ long currentMoment = System.currentTimeMillis() / 1000;
+
+ for (Object obj : periodicLimits) {
+ JSONObject limit = (JSONObject) obj;
+ BigDecimal amount = BigDecimal.
+ valueOf(Double.parseDouble(limit.getAsString(ConsentExtensionConstants.AMOUNT)));
+ long cyclicExpiryTime = Long.parseLong(limit.getAsString(ConsentExtensionConstants.CYCLIC_EXPIRY_TIME));
+ BigDecimal cyclicRemainingAmount = BigDecimal.
+ valueOf(Double.parseDouble(limit.getAsString(ConsentExtensionConstants.CYCLIC_REMAINING_AMOUNT)));
+
+ String periodType = limit.getAsString(ConsentExtensionConstants.PERIOD_TYPE);
+ String periodAlignment = limit.getAsString(ConsentExtensionConstants.PERIOD_ALIGNMENT);
+
+ PeriodicLimit periodicLimit = new PeriodicLimit(periodType, amount, periodAlignment);
+
+ if (currentMoment <= cyclicExpiryTime) {
+ if (instructedAmount.compareTo(cyclicRemainingAmount) > 0) {
+ return periodicLimitsList;
+ } else {
+ cyclicRemainingAmount = cyclicRemainingAmount.subtract(instructedAmount);
+ }
+ } else {
+ while (currentMoment > periodicLimit.getCyclicExpiryTime()) {
+ periodicLimit.setCyclicExpiryTime();
+ }
+ cyclicRemainingAmount = amount;
+ if (instructedAmount.compareTo(cyclicRemainingAmount) > 0) {
+ return periodicLimitsList;
+ } else {
+ cyclicRemainingAmount = cyclicRemainingAmount.subtract(instructedAmount);
+ }
+ }
+ periodicLimitsList.add(periodicLimit);
+ }
+
+ return periodicLimitsList;
+ }
+
+ /**
+ * Processes the given OBEvent. This method is part of the OBEventExecutor interface and needs to be implemented.
+ *
+ * @param obEvent The OBEvent to be processed
+ */
+ @Override
+ public void processEvent(OBEvent obEvent) {
+
+ }
+}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/impl/VRPConsentRequestHandler.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/impl/VRPConsentRequestHandler.java
index 2598e51d..9ff83ac1 100644
--- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/impl/VRPConsentRequestHandler.java
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/impl/VRPConsentRequestHandler.java
@@ -17,6 +17,7 @@
*/
package com.wso2.openbanking.accelerator.consent.extensions.manage.impl;
+import com.google.gson.Gson;
import com.wso2.openbanking.accelerator.common.exception.ConsentManagementException;
import com.wso2.openbanking.accelerator.common.util.ErrorConstants;
import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentException;
@@ -24,6 +25,7 @@
import com.wso2.openbanking.accelerator.consent.extensions.common.ConsentServiceUtil;
import com.wso2.openbanking.accelerator.consent.extensions.common.ResponseStatus;
import com.wso2.openbanking.accelerator.consent.extensions.manage.model.ConsentManageData;
+import com.wso2.openbanking.accelerator.consent.extensions.manage.model.PeriodicLimit;
import com.wso2.openbanking.accelerator.consent.extensions.manage.validator.VRPConsentRequestValidator;
import com.wso2.openbanking.accelerator.consent.extensions.util.ConsentManageUtil;
import com.wso2.openbanking.accelerator.consent.mgt.dao.models.ConsentResource;
@@ -36,11 +38,16 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import java.math.BigDecimal;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
-import static com.wso2.openbanking.accelerator.consent.extensions.common.ConsentExtensionConstants.AUTH_TYPE_AUTHORIZATION;
-import static com.wso2.openbanking.accelerator.consent.extensions.common.ConsentExtensionConstants.CREATED_STATUS;
+import static com.wso2.openbanking.accelerator.consent.extensions.common.
+ ConsentExtensionConstants.AUTH_TYPE_AUTHORIZATION;
+import static com.wso2.openbanking.accelerator.consent.extensions.
+ common.ConsentExtensionConstants.CREATED_STATUS;
/**
* Consent Manage request handler class for VRP Payment Request Validation.
@@ -159,74 +166,177 @@ public void handleConsentManageDelete(ConsentManageData consentManageData) {
public void handlePaymentPost(ConsentManageData consentManageData, Object request)
throws ConsentManagementException {
- if (request instanceof JSONObject) {
- JSONObject requestObject = (JSONObject) request;
+ // Check if the request is a JSONObject
+ if (!(request instanceof JSONObject)) {
+ log.error("Invalid request type. Expected JSONObject.");
+ throw new ConsentException(ResponseStatus.INTERNAL_SERVER_ERROR,
+ ErrorConstants.PAYLOAD_FORMAT_ERROR);
+ }
- // Create a ConsentResource representing the requested consent
- ConsentResource requestedConsent = new ConsentResource(consentManageData.getClientId(),
- requestObject.toJSONString(), ConsentExtensionConstants.VRP,
- ConsentExtensionConstants.AWAITING_AUTH_STATUS);
+ JSONObject requestObject = (JSONObject) request;
- // Create the consent
- DetailedConsentResource createdConsent = ConsentServiceUtil.getConsentService()
- .createAuthorizableConsent(requestedConsent, null,
- CREATED_STATUS, AUTH_TYPE_AUTHORIZATION, true);
+ // Create a ConsentResource representing the requested consent
+ ConsentResource requestedConsent = createRequestedConsent(consentManageData, requestObject);
- //Set consent attributes for storing
- Map consentAttributes = new HashMap<>();
- consentAttributes.put(ConsentExtensionConstants.IDEMPOTENCY_KEY, consentManageData.getHeaders()
- .get(ConsentExtensionConstants.X_IDEMPOTENCY_KEY));
+ // Create the consent
+ DetailedConsentResource createdConsent = createConsent(requestedConsent);
- consentManageData.setResponsePayload(ConsentManageUtil.getInitiationResponse(requestObject, createdConsent,
- consentManageData, ConsentExtensionConstants.VRP));
+ // Set consent attributes for storing
+ Map consentAttributes = createConsentAttributes(consentManageData);
- //Set Control Parameters as consent attributes to store
- JSONObject controlParameters = (JSONObject) ((JSONObject) ((JSONObject) consentManageData.getPayload())
- .get(ConsentExtensionConstants.DATA)).get(ConsentExtensionConstants.CONTROL_PARAMETERS);
+ // Store consent attributes
+ ConsentServiceUtil.getConsentService().storeConsentAttributes(createdConsent.getConsentID(),
+ consentAttributes);
- consentAttributes.put(ConsentExtensionConstants.MAXIMUM_INDIVIDUAL_AMOUNT,
- ((JSONObject) (controlParameters)
- .get(ConsentExtensionConstants.MAXIMUM_INDIVIDUAL_AMOUNT))
- .get(ConsentExtensionConstants.AMOUNT).toString());
+ // Set response payload and headers
+ setResponse(consentManageData, requestObject, createdConsent);
+ }
+
+ /**
+ * Method to Create a ConsentResource object using the provided ConsentManageData and requestObject.
+ *
+ * @param consentManageData Object containing request details
+ * @param requestObject JSON object representing the request
+ * @return ConsentResource object
+ */
+ private ConsentResource createRequestedConsent(ConsentManageData consentManageData, JSONObject requestObject) {
+ return new ConsentResource(consentManageData.getClientId(),
+ requestObject.toJSONString(), ConsentExtensionConstants.VRP,
+ ConsentExtensionConstants.AWAITING_AUTH_STATUS);
+ }
- consentAttributes.put(ConsentExtensionConstants.MAXIMUM_INDIVIDUAL_AMOUNT_CURRENCY,
- ((JSONObject) (controlParameters)
- .get(ConsentExtensionConstants.MAXIMUM_INDIVIDUAL_AMOUNT))
- .get(ConsentExtensionConstants.CURRENCY).toString());
+ /**
+ * Method to create a DetailedConsentResource object using the provided ConsentResource.
+ *
+ * @param requestedConsent ConsentResource object
+ * @return DetailedConsentResource object
+ * @throws ConsentManagementException if an error occurs while creating the consent
+ */
+ private DetailedConsentResource createConsent(ConsentResource requestedConsent) throws ConsentManagementException {
+ return ConsentServiceUtil.getConsentService()
+ .createAuthorizableConsent(requestedConsent, null,
+ CREATED_STATUS, AUTH_TYPE_AUTHORIZATION, true);
+ }
- consentAttributes.put(ConsentExtensionConstants.PERIOD_ALIGNMENT, ((JSONObject) ((JSONArray)
- (controlParameters).get(ConsentExtensionConstants.PERIODIC_LIMITS)).get(0))
- .get(ConsentExtensionConstants.PERIOD_ALIGNMENT).toString());
- //TODO: Improve the logic of storing the PERIODIC_LIMITS and rest of VRP parameters
+ /**
+ * Method to Create a map of consent attributes using the provided ConsentManageData.
+ *
+ * @param consentManageData Object containing request details
+ * @return Map of consent attributes
+ */
+ private Map createConsentAttributes(ConsentManageData consentManageData) {
+ Map consentAttributes = new HashMap<>();
+ consentAttributes.put(ConsentExtensionConstants.IDEMPOTENCY_KEY, consentManageData.getHeaders()
+ .get(ConsentExtensionConstants.X_IDEMPOTENCY_KEY));
- consentAttributes.put(ConsentExtensionConstants.PERIOD_TYPE,
- ((JSONObject) ((JSONArray) (controlParameters)
- .get(ConsentExtensionConstants.PERIODIC_LIMITS)).get(0)).get(ConsentExtensionConstants.PERIOD_TYPE)
- .toString());
+ JSONObject controlParameters = getControlParameters(consentManageData);
+ JSONArray periodicLimitsArray = (JSONArray) controlParameters.get(ConsentExtensionConstants.PERIODIC_LIMITS);
- consentAttributes.put(ConsentExtensionConstants.PERIOD_AMOUNT_LIMIT, ((JSONObject)
- ((JSONArray) (controlParameters).get(ConsentExtensionConstants.PERIODIC_LIMITS)).get(0))
- .get(ConsentExtensionConstants.PERIOD_AMOUNT_LIMIT).toString());
+ List periodicLimitsList = createPeriodicLimitsList(periodicLimitsArray);
- consentAttributes.put(ConsentExtensionConstants.PERIOD_LIMIT_CURRENCY, ((JSONObject)
- ((JSONArray) (controlParameters).get(ConsentExtensionConstants.PERIODIC_LIMITS)).get(0))
- .get(ConsentExtensionConstants.CURRENCY).toString());
+ JSONObject controlParams = createControlParameters(controlParameters, periodicLimitsList);
- //Store consent attributes
- ConsentServiceUtil.getConsentService().storeConsentAttributes(createdConsent.getConsentID(),
- consentAttributes);
+ // Convert the JSONObject to a string
+ String consentAttributesJson = controlParams.toJSONString();
- // Get request headers
- Map headers = consentManageData.getHeaders();
+ // Add the consentAttributesJson to the consentAttributes
+ consentAttributes.put(ConsentExtensionConstants.CONTROL_PARAMETERS, consentAttributesJson);
- consentManageData.setResponseHeader(ConsentExtensionConstants.X_IDEMPOTENCY_KEY,
- headers.get(ConsentExtensionConstants.X_IDEMPOTENCY_KEY));
- consentManageData.setResponseStatus(ResponseStatus.CREATED);
+ return consentAttributes;
+ }
- } else {
- log.error("Invalid request type. Expected JSONObject.");
- throw new ConsentException(ResponseStatus.INTERNAL_SERVER_ERROR,
- ErrorConstants.PAYLOAD_FORMAT_ERROR);
+ /**
+ * Method to retrieve control parameters from the provided ConsentManageData.
+ *
+ * @param consentManageData Object containing request details
+ * @return JSONObject of control parameters
+ */
+ private JSONObject getControlParameters(ConsentManageData consentManageData) {
+ return (JSONObject) ((JSONObject) ((JSONObject) consentManageData.getPayload())
+ .get(ConsentExtensionConstants.DATA)).get(ConsentExtensionConstants.CONTROL_PARAMETERS);
+ }
+
+ /**
+ * Method to create a list of PeriodicLimit objects from the provided JSONArray.
+ *
+ * @param periodicLimitsArray JSONArray of periodic limits
+ * @return List of PeriodicLimit objects
+ */
+ private List createPeriodicLimitsList(JSONArray periodicLimitsArray) {
+ List periodicLimitsList = new ArrayList<>();
+
+ for (Object periodicLimit : periodicLimitsArray) {
+ JSONObject jsonObject = (JSONObject) periodicLimit;
+ String periodType = (String) jsonObject.get(ConsentExtensionConstants.PERIOD_TYPE);
+ BigDecimal amount = BigDecimal.valueOf(Double.parseDouble((String) jsonObject.get(ConsentExtensionConstants.
+ AMOUNT)));
+ String periodAlignment = (String) jsonObject.get(ConsentExtensionConstants.PERIOD_ALIGNMENT);
+
+ PeriodicLimit periodicLimits = new PeriodicLimit(periodType, amount, periodAlignment);
+ periodicLimitsList.add(periodicLimits);
+ }
+
+ return periodicLimitsList;
+ }
+
+ /**
+ * Method to create JSONObject of control parameters using the provided JSONObject and
+ * list of PeriodicLimit objects.
+ *
+ * @param controlParameters JSONObject of control parameters
+ * @param periodicLimitsList List of PeriodicLimit objects
+ * @return JSONObject of control parameters
+ */
+ private JSONObject createControlParameters(JSONObject controlParameters, List periodicLimitsList) {
+ Gson gson = new Gson();
+
+ // Get MaximumIndividualAmount from controlParameters
+ JSONObject maximumIndividualAmountObject = (JSONObject) controlParameters.
+ get(ConsentExtensionConstants.MAXIMUM_INDIVIDUAL_AMOUNT);
+ double maximumIndividualAmount = Double.parseDouble(maximumIndividualAmountObject
+ .get(ConsentExtensionConstants.AMOUNT).toString());
+
+ // Create a new JSONObject
+ JSONObject jsonObject = new JSONObject();
+
+ // Add MaximumIndividualAmount to the JSONObject
+ jsonObject.put(ConsentExtensionConstants.MAXIMUM_INDIVIDUAL_AMOUNT, maximumIndividualAmount);
+
+ // Convert the periodicLimitsList to a JSON string
+ String periodicLimitsJson = gson.toJson(periodicLimitsList);
+
+ // Parse the JSON string back to a JSONArray
+ JSONArray newPeriodicLimitsArray;
+ try {
+ newPeriodicLimitsArray = (JSONArray) new JSONParser(JSONParser.MODE_PERMISSIVE).parse(periodicLimitsJson);
+ } catch (ParseException e) {
+ throw new RuntimeException("Error parsing JSON", e);
}
+
+ // Add the PeriodicLimits array to the JSONObject
+ jsonObject.put(ConsentExtensionConstants.PERIODIC_LIMITS, newPeriodicLimitsArray);
+
+ return jsonObject;
+ }
+
+ /**
+ * Method to set the response payload, headers, and status for the provided ConsentManageData using the
+ * provided requestObject and createdConsent.
+ *
+ * @param consentManageData Object containing request details
+ * @param requestObject JSON object representing the request
+ * @param createdConsent DetailedConsentResource object representing the created consent
+ */
+ private void setResponse(ConsentManageData consentManageData,
+ JSONObject requestObject, DetailedConsentResource createdConsent) {
+ consentManageData.setResponsePayload(ConsentManageUtil.getInitiationResponse(requestObject, createdConsent,
+ consentManageData, ConsentExtensionConstants.VRP));
+
+ // Get request headers
+ Map headers = consentManageData.getHeaders();
+
+ consentManageData.setResponseHeader(ConsentExtensionConstants.X_IDEMPOTENCY_KEY,
+ headers.get(ConsentExtensionConstants.X_IDEMPOTENCY_KEY));
+ consentManageData.setResponseStatus(ResponseStatus.CREATED);
}
}
diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/model/PeriodicLimit.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/model/PeriodicLimit.java
new file mode 100644
index 00000000..6bce52bb
--- /dev/null
+++ b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/manage/model/PeriodicLimit.java
@@ -0,0 +1,202 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *