From c334acc6a04c93c1baf13d40561200c8b105bfbf Mon Sep 17 00:00:00 2001 From: aka4rKO Date: Fri, 18 Oct 2024 15:44:54 +0530 Subject: [PATCH] handling cds common api with elected resources --- .../executors/core/CDSAPIRequestRouter.java | 9 +++++---- .../cds/gateway/utils/GatewayConstants.java | 5 +++++ .../resources/wso2am-4.2.0-deployment-cds.toml | 17 ++++------------- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/components/org.wso2.openbanking.cds.gateway/src/main/java/org/wso2/openbanking/cds/gateway/executors/core/CDSAPIRequestRouter.java b/components/org.wso2.openbanking.cds.gateway/src/main/java/org/wso2/openbanking/cds/gateway/executors/core/CDSAPIRequestRouter.java index f80915e0..6d474035 100644 --- a/components/org.wso2.openbanking.cds.gateway/src/main/java/org/wso2/openbanking/cds/gateway/executors/core/CDSAPIRequestRouter.java +++ b/components/org.wso2.openbanking.cds.gateway/src/main/java/org/wso2/openbanking/cds/gateway/executors/core/CDSAPIRequestRouter.java @@ -52,6 +52,11 @@ public List getExecutorsForRequest(OBAPIRequestConte requestContext.addContextProperty(RequestRouterConstants.API_TYPE_CUSTOM_PROP, RequestRouterConstants.API_TYPE_CDS_UNAUTHENTICATED); return this.getExecutorMap().get(RequestRouterConstants.CDS_UNAUTHENTICATED); + } else if (GatewayConstants.COMMON_ENDPOINTS.contains(requestContext.getMsgInfo() + .getElectedResource())) { + requestContext.addContextProperty(RequestRouterConstants.API_TYPE_CUSTOM_PROP, + RequestRouterConstants.API_TYPE_COMMON); + return this.getExecutorMap().get(RequestRouterConstants.CDS_COMMON); } else if (RequestRouterConstants.API_TYPE_CONSENT .equals(requestContext.getOpenAPI().getExtensions().get(RequestRouterConstants.API_TYPE_CUSTOM_PROP))) { // Add support for consent management portal APIs @@ -67,10 +72,6 @@ public List getExecutorsForRequest(OBAPIRequestConte requestContext.addContextProperty(RequestRouterConstants.API_TYPE_CUSTOM_PROP, RequestRouterConstants.API_TYPE_CDS); return this.getExecutorMap().get(RequestRouterConstants.CDS); - } else if (RequestRouterConstants.COMMON_API_NAME.equals(requestContext.getOpenAPI().getInfo().getTitle())) { - requestContext.addContextProperty(RequestRouterConstants.API_TYPE_CUSTOM_PROP, - RequestRouterConstants.API_TYPE_COMMON); - return this.getExecutorMap().get(RequestRouterConstants.CDS_COMMON); } else if (RequestRouterConstants.ADMIN_API_NAME.equals(requestContext.getOpenAPI().getInfo().getTitle())) { requestContext.addContextProperty(RequestRouterConstants.API_TYPE_CUSTOM_PROP, RequestRouterConstants.API_TYPE_ADMIN); diff --git a/components/org.wso2.openbanking.cds.gateway/src/main/java/org/wso2/openbanking/cds/gateway/utils/GatewayConstants.java b/components/org.wso2.openbanking.cds.gateway/src/main/java/org/wso2/openbanking/cds/gateway/utils/GatewayConstants.java index 2c3228ea..87aefe51 100644 --- a/components/org.wso2.openbanking.cds.gateway/src/main/java/org/wso2/openbanking/cds/gateway/utils/GatewayConstants.java +++ b/components/org.wso2.openbanking.cds.gateway/src/main/java/org/wso2/openbanking/cds/gateway/utils/GatewayConstants.java @@ -106,6 +106,8 @@ private GatewayConstants() { public static final String DISCOVERY_STATUS_ENDPOINT = "/discovery/status"; public static final String PRODUCTS_ENDPOINT = "/banking/products"; public static final String PRODUCT_DETAILS_ENDPOINT = "/banking/products/{productId}"; + public static final String COMMON_CUSTOMER_ENDPOINT = "/common/customer"; + public static final String COMMON_CUSTOMER_DETAIL_ENDPOINT = "/common/customer/detail"; public static final List INFOSEC_ENDPOINTS = Collections.unmodifiableList(Arrays.asList(AUTHORIZE_ENDPOINT, TOKEN_ENDPOINT, USERINFO_ENDPOINT, PAR_ENDPOINT, INTROSPECTION_ENDPOINT, JWKS_ENDPOINT, REVOKE_ENDPOINT, @@ -115,6 +117,9 @@ private GatewayConstants() { public static final List UNAUTHENTICATED_ENDPOINTS = Collections.unmodifiableList(Arrays.asList( PRODUCTS_ENDPOINT, PRODUCT_DETAILS_ENDPOINT, DISCOVERY_STATUS_ENDPOINT, DISCOVERY_OUTAGES_ENDPOINT)); + public static final List COMMON_ENDPOINTS = Collections.unmodifiableList(Arrays.asList( + COMMON_CUSTOMER_ENDPOINT, COMMON_CUSTOMER_DETAIL_ENDPOINT)); + public static final String UNKNOWN = "Unknown"; public static final String CLIENT_USER_AGENT = "User-Agent"; public static final String USER_NAME = "api.ut.userName"; diff --git a/toolkits/ob-apim/repository/resources/wso2am-4.2.0-deployment-cds.toml b/toolkits/ob-apim/repository/resources/wso2am-4.2.0-deployment-cds.toml index fa65dc30..3a61a02b 100644 --- a/toolkits/ob-apim/repository/resources/wso2am-4.2.0-deployment-cds.toml +++ b/toolkits/ob-apim/repository/resources/wso2am-4.2.0-deployment-cds.toml @@ -535,26 +535,17 @@ priority = 1000 [[open_banking.gateway.openbanking_gateway_executors.type]] name = "CDSUnauthenticated" [[open_banking.gateway.openbanking_gateway_executors.type.executors]] -name = "com.wso2.openbanking.accelerator.gateway.executor.impl.mtls.cert.validation.executor.CertRevocationValidationExecutor" -priority = 1 -[[open_banking.gateway.openbanking_gateway_executors.type.executors]] -name = "com.wso2.openbanking.accelerator.gateway.executor.impl.api.resource.access.validation.APIResourceAccessValidationExecutor" -priority = 2 -[[open_banking.gateway.openbanking_gateway_executors.type.executors]] name = "org.wso2.openbanking.cds.gateway.executors.idpermanence.IDPermanenceExecutor" -priority = 3 +priority = 1 [[open_banking.gateway.openbanking_gateway_executors.type.executors]] name = "org.wso2.openbanking.cds.gateway.executors.header.validation.CDSHeaderValidationExecutor" -priority = 4 -[[open_banking.gateway.openbanking_gateway_executors.type.executors]] -name = "com.wso2.openbanking.accelerator.gateway.executor.impl.consent.ConsentEnforcementExecutor" -priority = 5 +priority = 2 [[open_banking.gateway.openbanking_gateway_executors.type.executors]] name = "com.wso2.openbanking.accelerator.gateway.executor.impl.common.reporting.data.executor.CommonReportingDataExecutor" -priority = 6 +priority = 3 [[open_banking.gateway.openbanking_gateway_executors.type.executors]] name = "org.wso2.openbanking.cds.gateway.executors.reporting.CDSCommonDataReportingExecutor" -priority = 7 +priority = 4 [[open_banking.gateway.openbanking_gateway_executors.type.executors]] name = "org.wso2.openbanking.cds.gateway.executors.error.handler.CDSErrorHandler" priority = 1000