From 86b116c850f73f58e853d159f326944cd82171f3 Mon Sep 17 00:00:00 2001 From: Anju Chamantha Date: Thu, 8 Feb 2024 12:34:31 +0530 Subject: [PATCH 01/10] Add capability to disable authentication for DCR --- .../pom.xml | 5 ++ .../auth/valve/AuthenticationValve.java | 32 ++++++++ .../factory/DCRMgtOGSiServiceFactory.java | 73 +++++++++++++++++++ pom.xml | 6 ++ 4 files changed, 116 insertions(+) create mode 100644 components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/factory/DCRMgtOGSiServiceFactory.java diff --git a/components/org.wso2.carbon.identity.auth.valve/pom.xml b/components/org.wso2.carbon.identity.auth.valve/pom.xml index 7a8a76f5..a1a2d7e9 100644 --- a/components/org.wso2.carbon.identity.auth.valve/pom.xml +++ b/components/org.wso2.carbon.identity.auth.valve/pom.xml @@ -80,6 +80,11 @@ org.wso2.carbon.identity.inbound.auth.oauth2 org.wso2.carbon.identity.oauth + + org.wso2.carbon.identity.inbound.auth.oauth2 + org.wso2.carbon.identity.oauth.dcr + provided + org.json.wso2 json diff --git a/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java b/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java index db5ef1f3..ee62cbad 100644 --- a/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java +++ b/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java @@ -43,6 +43,7 @@ import org.wso2.carbon.identity.auth.service.module.ResourceConfigKey; import org.wso2.carbon.identity.auth.service.util.AuthConfigurationUtil; import org.wso2.carbon.identity.auth.service.util.Constants; +import org.wso2.carbon.identity.auth.valve.factory.DCRMgtOGSiServiceFactory; import org.wso2.carbon.identity.auth.valve.internal.AuthenticationValveDataHolder; import org.wso2.carbon.identity.auth.valve.internal.AuthenticationValveServiceHolder; import org.wso2.carbon.identity.auth.valve.util.APIErrorResponseHandler; @@ -51,6 +52,8 @@ import org.wso2.carbon.identity.core.util.IdentityConfigParser; import org.wso2.carbon.identity.core.util.IdentityTenantUtil; import org.wso2.carbon.identity.core.util.IdentityUtil; +import org.wso2.carbon.identity.oauth.dcr.exception.DCRMException; +import org.wso2.carbon.identity.oauth.dcr.model.DCRConfiguration; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.core.tenant.TenantManager; @@ -66,6 +69,7 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.HttpMethod; import static org.wso2.carbon.identity.auth.service.util.Constants.AUTHENTICATED_WITH_BASIC_AUTH; @@ -91,6 +95,8 @@ public class AuthenticationValve extends ValveBase { private static final Log log = LogFactory.getLog(AuthenticationValve.class); + public static final String DCR_REGISTER_ENDPOINT_PATH = "/api/identity/oauth2/dcr/v1.1/register/"; + @Override public void invoke(Request request, Response response) throws IOException, ServletException { @@ -107,6 +113,7 @@ public void invoke(Request request, Response response) throws IOException, Servl ResourceConfig securedResource = authenticationManager.getSecuredResource( new ResourceConfigKey(normalizedRequestURI, request.getMethod())); + overrideSecuredResource(securedResource, normalizedRequestURI, request.getMethod(), tenantDomain); setRemoteAddressAndUserAgentToMDC(request); @@ -173,6 +180,10 @@ public void invoke(Request request, Response response) throws IOException, Servl } catch (PatternSyntaxException e) { log.debug("Invalid pattern syntax of the request: ", e); APIErrorResponseHandler.handleErrorResponse(null, response, HttpServletResponse.SC_BAD_REQUEST, null); + } catch (DCRMException e) { + log.debug("Error while getting DCR Configuration: ", e); + APIErrorResponseHandler.handleErrorResponse(null, response, + HttpServletResponse.SC_SERVICE_UNAVAILABLE, e); } finally { // Clear 'IdentityError' thread local. if (IdentityUtil.getIdentityErrorMsg() != null) { @@ -200,6 +211,27 @@ public void invoke(Request request, Response response) throws IOException, Servl } + private void overrideSecuredResource(ResourceConfig securedResource, String normalizedRequestURI, String httpMethod, + String tenantDomain) throws DCRMException { + + if (DCR_REGISTER_ENDPOINT_PATH.equals(normalizedRequestURI) && HttpMethod.POST.equals(httpMethod)) { + + if (DCRMgtOGSiServiceFactory.getInstance() != null) { + + DCRConfiguration dcrConfiguration = DCRMgtOGSiServiceFactory.getInstance().getDCRConfiguration(tenantDomain); + Boolean isClientAuthenticationRequired = dcrConfiguration.isClientAuthenticationRequired(); + if (isClientAuthenticationRequired.equals(Boolean.TRUE)) { + securedResource.setIsSecured(true); + } else if (isClientAuthenticationRequired.equals(Boolean.FALSE)){ + securedResource.setIsSecured(false); + } + } else { +// We do not throw an exception here to avoid breaking the flow and to have similar behaviour as before. + log.debug("DCRMgtOGSiServiceFactory is null. Cannot get DCR Configuration."); + } + } + } + private void setRemoteAddressAndUserAgentToMDC(Request request) { String userAgent = request.getHeader(USER_AGENT); diff --git a/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/factory/DCRMgtOGSiServiceFactory.java b/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/factory/DCRMgtOGSiServiceFactory.java new file mode 100644 index 00000000..4a67b8cc --- /dev/null +++ b/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/factory/DCRMgtOGSiServiceFactory.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://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 org.wso2.carbon.identity.auth.valve.factory; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.identity.oauth.dcr.DCRConfigurationMgtService; + +/** + * Since this factory produces DCRConfigurationMgtService connector service, there is a possibility that said + * connector not available in the distribution. + * So rather than designing as Factory Beans this class designed as Singleton. + */ +public class DCRMgtOGSiServiceFactory { + + private static DCRConfigurationMgtService dcrConfigurationMgtService = null; + private static final Log log = LogFactory.getLog(DCRMgtOGSiServiceFactory.class); + + + /** + * This method return the instance if the OSGi service exists. + * Else throw Null pointer Exception. We handle the exception gracefully. + * + * @return DCRConfigurationMgtService + */ + public static DCRConfigurationMgtService getInstance() { + + if (dcrConfigurationMgtService == null) { + /* Try catch statement is included due to a NullPointerException which occurs at the server startup and + runtime when the DCRConfigurationMgtService is not available in the product. */ + + try { + // Call class for name to check the class is available in the run time. + // This method will call only once at the first api call. + Class.forName("org.wso2.carbon.identity.oauth.dcr.DCRConfigurationMgtService"); + DCRConfigurationMgtService taskOperationService + = (DCRConfigurationMgtService) PrivilegedCarbonContext. + getThreadLocalCarbonContext().getOSGiService + (DCRConfigurationMgtService.class, null); + if (taskOperationService != null) { + dcrConfigurationMgtService = taskOperationService; + } + + } catch (NullPointerException | ClassNotFoundException e) { + /* Catch block without implementation so that the DCRConfigurationMgtService will be set to null + in-turn helps in validating the rest API requests. */ + if (log.isDebugEnabled()) { + log.debug("Unable to find the DCRConfigurationMgtService. " + + "DCRConfigurationMgtService is not available in the server."); + } + } + } + + return dcrConfigurationMgtService; + } +} diff --git a/pom.xml b/pom.xml index 3ff3103d..c8461589 100644 --- a/pom.xml +++ b/pom.xml @@ -157,6 +157,12 @@ org.wso2.carbon.identity.oauth ${org.wso2.carbon.identity.oauth.version} + + org.wso2.carbon.identity.inbound.auth.oauth2 + org.wso2.carbon.identity.oauth.dcr + {org.wso2.carbon.identity.oauth.version} + provided + org.json.wso2 json From 2cdf93df7f9020f094a54f3a584843cd81a6e76e Mon Sep 17 00:00:00 2001 From: Anju Chamantha Date: Fri, 9 Feb 2024 10:17:35 +0530 Subject: [PATCH 02/10] Bug fix in disabling authentication for DCR tenant domains --- .../org.wso2.carbon.identity.auth.valve/pom.xml | 1 - .../identity/auth/valve/AuthenticationValve.java | 12 ++++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/components/org.wso2.carbon.identity.auth.valve/pom.xml b/components/org.wso2.carbon.identity.auth.valve/pom.xml index 6879749f..64f11576 100644 --- a/components/org.wso2.carbon.identity.auth.valve/pom.xml +++ b/components/org.wso2.carbon.identity.auth.valve/pom.xml @@ -83,7 +83,6 @@ org.wso2.carbon.identity.inbound.auth.oauth2 org.wso2.carbon.identity.oauth.dcr - provided org.json.wso2 diff --git a/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java b/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java index ee62cbad..d935b433 100644 --- a/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java +++ b/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java @@ -95,7 +95,7 @@ public class AuthenticationValve extends ValveBase { private static final Log log = LogFactory.getLog(AuthenticationValve.class); - public static final String DCR_REGISTER_ENDPOINT_PATH = "/api/identity/oauth2/dcr/v1.1/register/"; + public static final String DCR_REGISTER_ENDPOINT_PATH = "/api/identity/oauth2/dcr/v1.1/register"; @Override public void invoke(Request request, Response response) throws IOException, ServletException { @@ -211,10 +211,18 @@ public void invoke(Request request, Response response) throws IOException, Servl } + /** + * This method is used to override the secured resource based on tenant-wise DCR api security configuration. + * @param securedResource securedResource object + * @param normalizedRequestURI request URL path + * @param httpMethod http method + * @param tenantDomain tenant domain of the request + * @throws DCRMException DCRMException + */ private void overrideSecuredResource(ResourceConfig securedResource, String normalizedRequestURI, String httpMethod, String tenantDomain) throws DCRMException { - if (DCR_REGISTER_ENDPOINT_PATH.equals(normalizedRequestURI) && HttpMethod.POST.equals(httpMethod)) { + if (normalizedRequestURI.contains(DCR_REGISTER_ENDPOINT_PATH) && HttpMethod.POST.equals(httpMethod)) { if (DCRMgtOGSiServiceFactory.getInstance() != null) { From bef486a59d9f66341b971256febb8d74dfafc6ec Mon Sep 17 00:00:00 2001 From: Anju Chamantha Date: Fri, 9 Feb 2024 10:19:00 +0530 Subject: [PATCH 03/10] Bump inbound oauth version --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 6c2afc69..c1c29718 100644 --- a/pom.xml +++ b/pom.xml @@ -160,7 +160,7 @@ org.wso2.carbon.identity.inbound.auth.oauth2 org.wso2.carbon.identity.oauth.dcr - {org.wso2.carbon.identity.oauth.version} + ${org.wso2.carbon.identity.oauth.version} provided @@ -359,7 +359,7 @@ 5.25.652 [5.17.8, 8.0.0) - 6.11.168 + 7.0.9 [6.2.18, 8.0.0) From cf153350999a4fa1b825b6ac9b04199c1f9b3585 Mon Sep 17 00:00:00 2001 From: Anju Chamantha Date: Fri, 16 Feb 2024 09:20:17 +0530 Subject: [PATCH 04/10] Change DCR configuration name --- .../wso2/carbon/identity/auth/valve/AuthenticationValve.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java b/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java index d935b433..0a129dfc 100644 --- a/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java +++ b/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java @@ -226,8 +226,8 @@ private void overrideSecuredResource(ResourceConfig securedResource, String norm if (DCRMgtOGSiServiceFactory.getInstance() != null) { - DCRConfiguration dcrConfiguration = DCRMgtOGSiServiceFactory.getInstance().getDCRConfiguration(tenantDomain); - Boolean isClientAuthenticationRequired = dcrConfiguration.isClientAuthenticationRequired(); + DCRConfiguration dcrConfiguration = DCRMgtOGSiServiceFactory.getInstance().getDCRConfiguration(); + Boolean isClientAuthenticationRequired = dcrConfiguration.isAuthenticationRequired(); if (isClientAuthenticationRequired.equals(Boolean.TRUE)) { securedResource.setIsSecured(true); } else if (isClientAuthenticationRequired.equals(Boolean.FALSE)){ From be5add745012100f9bcd0720af76c2d8c3993edc Mon Sep 17 00:00:00 2001 From: Anju Chamantha Date: Thu, 4 Apr 2024 11:55:49 +0530 Subject: [PATCH 05/10] [DCR Config] Null pointer bug fix --- .../wso2/carbon/identity/auth/valve/AuthenticationValve.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java b/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java index 0a129dfc..f42ee393 100644 --- a/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java +++ b/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java @@ -228,9 +228,9 @@ private void overrideSecuredResource(ResourceConfig securedResource, String norm DCRConfiguration dcrConfiguration = DCRMgtOGSiServiceFactory.getInstance().getDCRConfiguration(); Boolean isClientAuthenticationRequired = dcrConfiguration.isAuthenticationRequired(); - if (isClientAuthenticationRequired.equals(Boolean.TRUE)) { + if ((Boolean.TRUE).equals(isClientAuthenticationRequired)) { securedResource.setIsSecured(true); - } else if (isClientAuthenticationRequired.equals(Boolean.FALSE)){ + } else if ((Boolean.FALSE).equals(isClientAuthenticationRequired)) { securedResource.setIsSecured(false); } } else { From 0670d2967158bc1ea122578ad32566ba7ce70d27 Mon Sep 17 00:00:00 2001 From: Anju Chamantha Date: Thu, 4 Apr 2024 11:55:49 +0530 Subject: [PATCH 06/10] [DCR Config] Refactor DCR config methods --- .../identity/auth/valve/AuthenticationValve.java | 14 +++++++------- .../valve/factory/DCRMgtOGSiServiceFactory.java | 5 +---- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java b/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java index 0a129dfc..81ad3f26 100644 --- a/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java +++ b/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java @@ -95,7 +95,7 @@ public class AuthenticationValve extends ValveBase { private static final Log log = LogFactory.getLog(AuthenticationValve.class); - public static final String DCR_REGISTER_ENDPOINT_PATH = "/api/identity/oauth2/dcr/v1.1/register"; + private static final String DCR_REGISTER_ENDPOINT_PATH = "/api/identity/oauth2/dcr/v1.1/register"; @Override public void invoke(Request request, Response response) throws IOException, ServletException { @@ -113,7 +113,7 @@ public void invoke(Request request, Response response) throws IOException, Servl ResourceConfig securedResource = authenticationManager.getSecuredResource( new ResourceConfigKey(normalizedRequestURI, request.getMethod())); - overrideSecuredResource(securedResource, normalizedRequestURI, request.getMethod(), tenantDomain); + overrideSecuredResource(securedResource, normalizedRequestURI, request.getMethod()); setRemoteAddressAndUserAgentToMDC(request); @@ -213,14 +213,14 @@ public void invoke(Request request, Response response) throws IOException, Servl /** * This method is used to override the secured resource based on tenant-wise DCR api security configuration. + * * @param securedResource securedResource object * @param normalizedRequestURI request URL path * @param httpMethod http method - * @param tenantDomain tenant domain of the request * @throws DCRMException DCRMException */ - private void overrideSecuredResource(ResourceConfig securedResource, String normalizedRequestURI, String httpMethod, - String tenantDomain) throws DCRMException { + private void overrideSecuredResource(ResourceConfig securedResource, String normalizedRequestURI, + String httpMethod) throws DCRMException { if (normalizedRequestURI.contains(DCR_REGISTER_ENDPOINT_PATH) && HttpMethod.POST.equals(httpMethod)) { @@ -228,9 +228,9 @@ private void overrideSecuredResource(ResourceConfig securedResource, String norm DCRConfiguration dcrConfiguration = DCRMgtOGSiServiceFactory.getInstance().getDCRConfiguration(); Boolean isClientAuthenticationRequired = dcrConfiguration.isAuthenticationRequired(); - if (isClientAuthenticationRequired.equals(Boolean.TRUE)) { + if ((Boolean.TRUE).equals(isClientAuthenticationRequired)) { securedResource.setIsSecured(true); - } else if (isClientAuthenticationRequired.equals(Boolean.FALSE)){ + } else if ((Boolean.FALSE).equals(isClientAuthenticationRequired)) { securedResource.setIsSecured(false); } } else { diff --git a/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/factory/DCRMgtOGSiServiceFactory.java b/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/factory/DCRMgtOGSiServiceFactory.java index 4a67b8cc..6b95a936 100644 --- a/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/factory/DCRMgtOGSiServiceFactory.java +++ b/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/factory/DCRMgtOGSiServiceFactory.java @@ -33,7 +33,6 @@ public class DCRMgtOGSiServiceFactory { private static DCRConfigurationMgtService dcrConfigurationMgtService = null; private static final Log log = LogFactory.getLog(DCRMgtOGSiServiceFactory.class); - /** * This method return the instance if the OSGi service exists. * Else throw Null pointer Exception. We handle the exception gracefully. @@ -61,10 +60,8 @@ public static DCRConfigurationMgtService getInstance() { } catch (NullPointerException | ClassNotFoundException e) { /* Catch block without implementation so that the DCRConfigurationMgtService will be set to null in-turn helps in validating the rest API requests. */ - if (log.isDebugEnabled()) { - log.debug("Unable to find the DCRConfigurationMgtService. " + + log.debug("Unable to find the DCRConfigurationMgtService. " + "DCRConfigurationMgtService is not available in the server."); - } } } From 0b159f19942e188fe8ce8e4c427748c3bc23e08c Mon Sep 17 00:00:00 2001 From: Anju Chamantha Date: Mon, 15 Apr 2024 08:24:24 +0530 Subject: [PATCH 07/10] [DCR Config] Remove unnecessary `provided` scope --- pom.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index e4b28d0e..c44529b6 100644 --- a/pom.xml +++ b/pom.xml @@ -161,7 +161,6 @@ org.wso2.carbon.identity.inbound.auth.oauth2 org.wso2.carbon.identity.oauth.dcr ${org.wso2.carbon.identity.oauth.version} - provided org.json.wso2 @@ -359,7 +358,7 @@ 5.25.652 [5.17.8, 8.0.0) - 7.0.18 + 7.0.42-SNAPSHOT [6.2.18, 8.0.0) From 1a9357bf64f76553525bb96ff2932181094deb39 Mon Sep 17 00:00:00 2001 From: Anju Chamantha Date: Mon, 15 Apr 2024 08:30:50 +0530 Subject: [PATCH 08/10] [DCR Config] Change debug log to error log --- .../wso2/carbon/identity/auth/valve/AuthenticationValve.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java b/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java index 81ad3f26..3707892a 100644 --- a/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java +++ b/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java @@ -181,7 +181,7 @@ public void invoke(Request request, Response response) throws IOException, Servl log.debug("Invalid pattern syntax of the request: ", e); APIErrorResponseHandler.handleErrorResponse(null, response, HttpServletResponse.SC_BAD_REQUEST, null); } catch (DCRMException e) { - log.debug("Error while getting DCR Configuration: ", e); + log.error("Error while getting DCR Configuration: ", e); APIErrorResponseHandler.handleErrorResponse(null, response, HttpServletResponse.SC_SERVICE_UNAVAILABLE, e); } finally { From 93eeaf00afe26d71de0f0d1d0ae3d8a71bd12584 Mon Sep 17 00:00:00 2001 From: Anju Chamantha Date: Mon, 15 Apr 2024 10:31:59 +0530 Subject: [PATCH 09/10] [DCR Config] Refactoring variable and method names --- .../identity/auth/valve/AuthenticationValve.java | 2 +- .../auth/valve/factory/DCRMgtOGSiServiceFactory.java | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java b/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java index 3707892a..a0d911a8 100644 --- a/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java +++ b/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/AuthenticationValve.java @@ -227,7 +227,7 @@ private void overrideSecuredResource(ResourceConfig securedResource, String norm if (DCRMgtOGSiServiceFactory.getInstance() != null) { DCRConfiguration dcrConfiguration = DCRMgtOGSiServiceFactory.getInstance().getDCRConfiguration(); - Boolean isClientAuthenticationRequired = dcrConfiguration.isAuthenticationRequired(); + Boolean isClientAuthenticationRequired = dcrConfiguration.getAuthenticationRequired(); if ((Boolean.TRUE).equals(isClientAuthenticationRequired)) { securedResource.setIsSecured(true); } else if ((Boolean.FALSE).equals(isClientAuthenticationRequired)) { diff --git a/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/factory/DCRMgtOGSiServiceFactory.java b/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/factory/DCRMgtOGSiServiceFactory.java index 6b95a936..94aa4e82 100644 --- a/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/factory/DCRMgtOGSiServiceFactory.java +++ b/components/org.wso2.carbon.identity.auth.valve/src/main/java/org/wso2/carbon/identity/auth/valve/factory/DCRMgtOGSiServiceFactory.java @@ -49,18 +49,16 @@ public static DCRConfigurationMgtService getInstance() { // Call class for name to check the class is available in the run time. // This method will call only once at the first api call. Class.forName("org.wso2.carbon.identity.oauth.dcr.DCRConfigurationMgtService"); - DCRConfigurationMgtService taskOperationService - = (DCRConfigurationMgtService) PrivilegedCarbonContext. - getThreadLocalCarbonContext().getOSGiService - (DCRConfigurationMgtService.class, null); - if (taskOperationService != null) { - dcrConfigurationMgtService = taskOperationService; + DCRConfigurationMgtService dcrConfigMgtService = (DCRConfigurationMgtService) PrivilegedCarbonContext + .getThreadLocalCarbonContext().getOSGiService(DCRConfigurationMgtService.class, null); + if (dcrConfigMgtService != null) { + dcrConfigurationMgtService = dcrConfigMgtService; } } catch (NullPointerException | ClassNotFoundException e) { /* Catch block without implementation so that the DCRConfigurationMgtService will be set to null in-turn helps in validating the rest API requests. */ - log.debug("Unable to find the DCRConfigurationMgtService. " + + log.error("Unable to find the DCRConfigurationMgtService. " + "DCRConfigurationMgtService is not available in the server."); } } From 067e2a6fd1ffa69d9910ead552d4369052a8bd2c Mon Sep 17 00:00:00 2001 From: Anju Chamantha Date: Thu, 9 May 2024 11:41:12 +0530 Subject: [PATCH 10/10] Bump identity-inbound-auth-oauth version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c44529b6..77c14278 100644 --- a/pom.xml +++ b/pom.xml @@ -358,7 +358,7 @@ 5.25.652 [5.17.8, 8.0.0) - 7.0.42-SNAPSHOT + 7.0.65 [6.2.18, 8.0.0)