From d107f0760ab0872384f477dd7363f2f884bf7b9f Mon Sep 17 00:00:00 2001 From: aka4rKO Date: Thu, 12 Dec 2024 15:27:48 +0530 Subject: [PATCH 1/2] fixed cds authentication webapp page refresh issue --- .../impl/OBCDSAuthServletImpl.java | 8 +- .../impl/OBCDSAuthServletImplTests.java | 2 +- .../ob#authenticationendpoint/WEB-INF/web.xml | 20 +++ .../oauth2_authz_displayconsent.jsp | 132 +++++++++++------- .../ob#authenticationendpoint/ob_cds.jsp | 85 +++++++++++ .../ob_cds_account_selection.jsp | 103 +++++++------- .../ob_cds_profile_selection.jsp | 21 +-- 7 files changed, 241 insertions(+), 130 deletions(-) create mode 100644 toolkits/ob-is/carbon-home/repository/deployment/server/webapps/ob#authenticationendpoint/ob_cds.jsp diff --git a/components/org.wso2.openbanking.cds.consent.extensions/src/main/java/org/wso2/openbanking/cds/consent/extensions/authservlet/impl/OBCDSAuthServletImpl.java b/components/org.wso2.openbanking.cds.consent.extensions/src/main/java/org/wso2/openbanking/cds/consent/extensions/authservlet/impl/OBCDSAuthServletImpl.java index 6e04b83f..10f74825 100644 --- a/components/org.wso2.openbanking.cds.consent.extensions/src/main/java/org/wso2/openbanking/cds/consent/extensions/authservlet/impl/OBCDSAuthServletImpl.java +++ b/components/org.wso2.openbanking.cds.consent.extensions/src/main/java/org/wso2/openbanking/cds/consent/extensions/authservlet/impl/OBCDSAuthServletImpl.java @@ -214,12 +214,8 @@ public Map updateConsentMetaData(HttpServletRequest httpServletR @Override public String getJSPPath() { - // If profile is already selected, skip the profile selection page - if (StringUtils.isBlank(preSelectedProfileId)) { - return "/ob_cds_profile_selection.jsp"; - } else { - return "/ob_cds_account_selection.jsp"; - } + // Moving the logic of determining the 1st page (profile selection or account selection) to ob_cds.jsp file + return "/ob_cds.jsp"; } /** diff --git a/components/org.wso2.openbanking.cds.consent.extensions/src/test/java/org/wso2/openbanking/cds/consent/extensions/authservlet/impl/OBCDSAuthServletImplTests.java b/components/org.wso2.openbanking.cds.consent.extensions/src/test/java/org/wso2/openbanking/cds/consent/extensions/authservlet/impl/OBCDSAuthServletImplTests.java index 6949ed60..1144b295 100644 --- a/components/org.wso2.openbanking.cds.consent.extensions/src/test/java/org/wso2/openbanking/cds/consent/extensions/authservlet/impl/OBCDSAuthServletImplTests.java +++ b/components/org.wso2.openbanking.cds.consent.extensions/src/test/java/org/wso2/openbanking/cds/consent/extensions/authservlet/impl/OBCDSAuthServletImplTests.java @@ -184,6 +184,6 @@ public void testUpdateConsentMetaData() { @Test public void testGetJSPPath() { String jspPath = obCdsAuthServlet.getJSPPath(); - Assert.assertEquals(jspPath, "/ob_cds_profile_selection.jsp"); + Assert.assertEquals(jspPath, "/ob_cds.jsp"); } } diff --git a/toolkits/ob-is/carbon-home/repository/deployment/server/webapps/ob#authenticationendpoint/WEB-INF/web.xml b/toolkits/ob-is/carbon-home/repository/deployment/server/webapps/ob#authenticationendpoint/WEB-INF/web.xml index 276420a9..7eb8bec4 100644 --- a/toolkits/ob-is/carbon-home/repository/deployment/server/webapps/ob#authenticationendpoint/WEB-INF/web.xml +++ b/toolkits/ob-is/carbon-home/repository/deployment/server/webapps/ob#authenticationendpoint/WEB-INF/web.xml @@ -91,6 +91,16 @@ /ob_cds_account_selection.do + + ob_cds_profile_selection.do + /ob_cds_profile_selection.do + + + + ob_cds.do + /ob_cds.do + + retry.do /generic-exception-response.jsp @@ -106,6 +116,16 @@ /ob_cds_account_selection.jsp + + ob_cds_profile_selection.do + /ob_cds_profile_selection.jsp + + + + ob_cds.do + /ob_cds.jsp + + retry.do /retry.do diff --git a/toolkits/ob-is/carbon-home/repository/deployment/server/webapps/ob#authenticationendpoint/oauth2_authz_displayconsent.jsp b/toolkits/ob-is/carbon-home/repository/deployment/server/webapps/ob#authenticationendpoint/oauth2_authz_displayconsent.jsp index a0de01d8..a6874c57 100644 --- a/toolkits/ob-is/carbon-home/repository/deployment/server/webapps/ob#authenticationendpoint/oauth2_authz_displayconsent.jsp +++ b/toolkits/ob-is/carbon-home/repository/deployment/server/webapps/ob#authenticationendpoint/oauth2_authz_displayconsent.jsp @@ -28,26 +28,33 @@ <% - String sessionDataKeyConsent = getRequestAttribute(request, "sessionDataKeyConsent"); - String isConsentAmendment = getRequestAttribute(request, "isConsentAmendment"); - String isSharingDurationUpdated = getRequestAttribute(request, "isSharingDurationUpdated"); - String accounts = getRequestAttribute(request, "accountsArry[]"); - String[] accountDisplayNameList = null; - String accounNames = getRequestAttribute(request, "accNames"); - String appName = getRequestAttribute(request, "app"); - String spFullName = getRequestAttribute(request, "spFullName"); - String consentId = request.getParameter("id"); - String userName = request.getParameter("user"); - String selectedProfileId = getRequestAttribute(request, "selectedProfileId"); - String selectedProfileName = getRequestAttribute(request, "selectedProfileName"); - String[] accountList = accounNames.split(":"); - String consentExpiryDateTime = getRequestAttribute(request, "consent-expiry-date"); + + String accounts = (String) getAttribute(request, session, "accountsArry[]", null); + session.setAttribute("accounts", accounts); + + String accountNames = (String) getAttribute(request, session, "accNames", null); + String[] accountList = accountNames.split(":"); + session.setAttribute("accountList", accountList); + + String userName = (String) getAttribute(request, session, "user", null); + session.setAttribute("userName", userName); + + String selectedProfileName = (String) getAttribute(request, session, "selectedProfileName", null); + session.setAttribute("selectedProfileName", selectedProfileName); + + String consentExpiryDateTime = (String) getAttribute(request, session, "consent_expiration", null); + String consentExpiryDate = consentExpiryDateTime.split("T")[0]; + session.setAttribute("consentExpiryDate", consentExpiryDate); + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd"); LocalDateTime now = LocalDateTime.now(); String currentDate = dtf.format(now); + session.setAttribute("currentDate", currentDate); + Map> consentData; Map> newConsentData; + String selectedProfileId = (String) getAttribute(request, session, "selectedProfileId", null); if ("individual_profile".equalsIgnoreCase(selectedProfileId)) { consentData = (Map>) session.getAttribute("configParamsMap"); newConsentData = (Map>) session.getAttribute("newConfigParamsMap"); @@ -55,10 +62,10 @@ consentData = (Map>) session.getAttribute("business_data_cluster"); newConsentData = (Map>) session.getAttribute("new_business_data_cluster"); } + session.setAttribute("consentData", consentData); + session.setAttribute("newConsentData", newConsentData); session.setAttribute("configParamsMap", consentData); session.setAttribute("newConfigParamsMap", newConsentData); - session.setAttribute("isConsentAmendment", isConsentAmendment); - session.setAttribute("isSharingDurationUpdated", isSharingDurationUpdated); boolean isSharedWithinDay = true; if (!"Single use consent".equals(consentExpiryDateTime)) { @@ -69,16 +76,20 @@ } } session.setAttribute("isSharedWithinDay", isSharedWithinDay); - String nameClaims = (String) session.getAttribute("nameClaims"); - String contactClaims = (String) session.getAttribute("contactClaims"); - boolean skipAccounts = (boolean) session.getAttribute("skipAccounts"); + int sharingDurationValue = 0; - if (getRequestAttribute(request, "sharing_duration_value") != null) { - sharingDurationValue = Integer.parseInt(getRequestAttribute(request, "sharing_duration_value")); + if (getAttribute(request, session, "sharing_duration_value", null) != null) { + sharingDurationValue = Integer.parseInt(getAttribute(request, session, "sharing_duration_value", null).toString()); + session.setAttribute("sharingDurationValue", sharingDurationValue); } + + boolean skipAccounts = (boolean) session.getAttribute("skipAccounts"); + String[] accountDisplayNameList = null; if (!skipAccounts) { - accountDisplayNameList = getRequestAttribute(request, "accDisplayNames").split(":"); + accountDisplayNameList = ((String) getAttribute(request, session, "accDisplayNames", null)).split(":"); + session.setAttribute("accountDisplayNameList", accountDisplayNameList); } + %>
@@ -88,7 +99,7 @@