Repository: wso2/carbon-identity-framework
Pull request #6721: Migrate to use Apache HTTP Client 5
Author: login: linukaratnayake
Created: 2025-05-08T09:09:33Z | Merged: 2025-05-22T10:57:35Z

### Proposed changes in this pull request
<!--
[List all changes you want to add here. If you fixed an issue, please
add a reference to that issue as well.]
-->
- Modify the classes and their respective tests to use Apache HTTP Client 5, instead of previously used Apache HTTP Client 4.
- Methods in the Carbon Kernel (see PR mentioned below) are used for creating HTTP clients.

### When should this PR be merged
<!--
[Please describe any preconditions that need to be addressed before we
can merge this pull request.]
-->
- https://github.com/wso2/carbon-kernel/pull/4302 must be merged before merging this pull request.

<!--
### Follow up actions

[List any possible follow-up actions here; for instance, testing data
migrations, software that we need to install on staging and production
environments.]

-
-->

### Checklist (for reviewing)

#### General

- [ ] **Is this PR explained thoroughly?** All code changes must be accounted for in the PR description.
- [ ] **Is the PR labeled correctly?**

#### Functionality

- [ ] **Are all requirements met?** Compare implemented functionality with the requirements specification.
- [ ] **Does the UI work as expected?** There should be no Javascript errors in the console; all resources should load. There should be no unexpected errors. Deliberately try to break the feature to find out if there are corner cases that are not handled.

#### Code

- [ ] **Do you fully understand the introduced changes to the code?** If not ask for clarification, it might uncover ways to solve a problem in a more elegant and efficient way.
- [ ] **Does the PR introduce any inefficient database requests?** Use the debug server to check for duplicate requests.
- [ ] **Are all necessary strings marked for translation?** All strings that are exposed to users via the UI must be [marked for translation](https://docs.djangoproject.com/en/1.10/topics/i18n/translation/).

#### Tests

- [ ] **Are there sufficient test cases?** Ensure that all components are tested individually; models, forms, and serializers should be tested in isolation even if a test for a view covers these components.
- [ ] **If this is a bug fix, are tests for the issue in place?**  There must be a test case for the bug to ensure the issue won’t regress. Make sure that the tests break without the new code to fix the issue.
- [ ] **If this is a new feature or a significant change to an existing feature?** has the manual testing spreadsheet been updated with instructions for manual testing?

#### Security

- [ ] **Confirm this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.**
- [ ] **Are all UI and API inputs run through forms or serializers?**
- [ ] **Are all external inputs validated and sanitized appropriately?**
- [ ] **Does all branching logic have a default case?**
- [ ] **Does this solution handle outliers and edge cases gracefully?**
- [ ] **Are all external communications secured and restricted to SSL?**

#### Documentation

- [ ] **Are changes to the UI documented in the platform docs?** If this PR introduces new platform site functionality or changes existing ones, the changes should be documented.
- [ ] **Are changes to the API documented in the API docs?** If this PR introduces new API functionality or changes existing ones, the changes must be documented.
- [ ] **Are reusable components documented?** If this PR introduces components that are relevant to other developers (for instance a mixin for a view or a generic form) they should be documented in the Wiki.



Diff:
diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.endpoint.util/pom.xml b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.endpoint.util/pom.xml
index 8587b809dc33..a19aadbc1117 100644
--- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.endpoint.util/pom.xml
+++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.endpoint.util/pom.xml
@@ -128,14 +128,6 @@
             <groupId>org.wso2.orbit.javax.xml.bind</groupId>
             <artifactId>jaxb-api</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.wso2.orbit.org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.httpcomponents.wso2</groupId>
-            <artifactId>httpcore</artifactId>
-        </dependency>
         <dependency>
             <groupId>org.json.wso2</groupId>
             <artifactId>json</artifactId>
@@ -145,6 +137,14 @@
             <artifactId>org.wso2.carbon.identity.testutil</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.wso2.orbit.org.apache.httpcomponents</groupId>
+            <artifactId>httpcore5</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.orbit.org.apache.httpcomponents</groupId>
+            <artifactId>httpclient5</artifactId>
+        </dependency>
     </dependencies>
 
     <build>
@@ -179,9 +179,8 @@
                             org.apache.commons.codec.binary; version="${commons-codec.wso2.osgi.version.range}",
                             org.apache.commons.lang; version="${commons-lang.wso2.osgi.version.range}",
                             org.apache.commons.logging.*; version="${import.package.version.commons.logging}",
-                            org.apache.http; version="${httpcore.version.osgi.import.range}",
-                            org.apache.http.client.methods; version="${httpcomponents-httpclient.imp.pkg.version.range}",
-                            org.apache.http.impl.client; version="${httpcomponents-httpclient.imp.pkg.version.range}",
+                            org.apache.hc.client5.http; version="${orbit.version.httpclient5}",
+                            org.apache.hc.core5.http; version="${orbit.version.httpcore5}",
                             org.json; version="${json.wso2.version.range}",
                             org.wso2.carbon.identity.user.registration.stub.*;version="${carbon.identity.package.import.version.range}",
                             org.apache.axis2.*;version="${axis2.osgi.version.range}",
diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.endpoint.util/src/main/java/org/wso2/carbon/identity/application/authentication/endpoint/util/AuthenticationEndpointUtil.java b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.endpoint.util/src/main/java/org/wso2/carbon/identity/application/authentication/endpoint/util/AuthenticationEndpointUtil.java
index fa9fbed8c256..132dec57ba38 100644
--- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.endpoint.util/src/main/java/org/wso2/carbon/identity/application/authentication/endpoint/util/AuthenticationEndpointUtil.java
+++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.endpoint.util/src/main/java/org/wso2/carbon/identity/application/authentication/endpoint/util/AuthenticationEndpointUtil.java
@@ -24,14 +24,14 @@
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpStatus;
-import org.apache.http.NameValuePair;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.client.utils.URLEncodedUtils;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.message.BasicNameValuePair;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.NameValuePair;
+import org.apache.hc.core5.http.message.BasicNameValuePair;
+import org.apache.hc.core5.net.URLEncodedUtils;
 import org.owasp.encoder.Encode;
 import org.wso2.carbon.context.PrivilegedCarbonContext;
 import org.wso2.carbon.identity.application.authentication.endpoint.util.bean.UserDTO;
@@ -41,7 +41,7 @@
 import org.wso2.carbon.identity.core.util.IdentityTenantUtil;
 import org.wso2.carbon.user.core.UserCoreConstants;
 import org.wso2.carbon.user.core.util.UserCoreUtil;
-import org.wso2.carbon.utils.HTTPClientUtils;
+import org.wso2.carbon.utils.httpclient5.HTTPClientUtils;
 import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
 
 import java.io.BufferedReader;
@@ -375,26 +375,23 @@ private static String buildAbsoluteURL(String contextPath) throws URLBuilderExce
      */
     public static String sendGetRequest(String backendURL) {
 
-        StringBuilder responseString = new StringBuilder();
-        try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomVerifier().build()) {
+        try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomHostnameVerifier().build()) {
 
             HttpGet httpGet = new HttpGet(backendURL);
             setAuthorizationHeader(httpGet);
 
-            try (CloseableHttpResponse response = httpclient.execute(httpGet)) {
-
+            return httpclient.execute(httpGet, response -> {
                 if (log.isDebugEnabled()) {
-                    log.debug("HTTP status " + response.getStatusLine().getStatusCode() +
+                    log.debug("HTTP status " + response.getCode() +
                             " when invoking " + HTTP_METHOD_GET + " for URL: " + backendURL);
                 }
-                responseString = handleHttpResponse(response, backendURL);
-            } finally {
-                httpGet.releaseConnection();
-            }
+                return handleHttpResponse(response, backendURL);
+            });
+
         } catch (IOException e) {
             log.error("Sending " + HTTP_METHOD_GET + " request to URL : " + backendURL + ", failed.", e);
         }
-        return responseString.toString();
+        return StringUtils.EMPTY;
     }
 
     /**
@@ -405,11 +402,12 @@ public static String sendGetRequest(String backendURL) {
      * @return Extracted http response content.
      * @throws IOException if there is an error while extracting the response content.
      */
-    private static StringBuilder handleHttpResponse(CloseableHttpResponse response, String backendURL) throws IOException {
+    private static String handleHttpResponse(ClassicHttpResponse response, String backendURL)
+            throws IOException {
 
         StringBuilder responseString = new StringBuilder();
 
-        if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+        if (response.getCode() == HttpStatus.SC_OK) {
             try (BufferedReader reader = new BufferedReader(new InputStreamReader(
                     response.getEntity().getContent()))) {
                 String inputLine;
@@ -417,17 +415,17 @@ private static StringBuilder handleHttpResponse(CloseableHttpResponse response,
                     responseString.append(inputLine);
                 }
             }
-        } else if (response.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_FOUND) {
+        } else if (response.getCode() == HttpStatus.SC_NOT_FOUND) {
             if (log.isDebugEnabled()) {
                 log.debug("Response received from the backendURL " + backendURL + " with status " +
-                        response.getStatusLine() + ".");
+                        response.getCode() + ".");
             }
         } else {
-            log.error("Response received from the backendURL " + backendURL +" failed with status " +
-                    response.getStatusLine() + ".");
+            log.error("Response received from the backendURL " + backendURL + " failed with status " +
+                    response.getCode() + ".");
         }
 
-        return responseString;
+        return responseString.toString();
     }
 
     /**
@@ -435,7 +433,7 @@ private static StringBuilder handleHttpResponse(CloseableHttpResponse response,
      *
      * @param httpMethod The HttpMethod which needs the authorization header.
      */
-    private static void setAuthorizationHeader(HttpRequestBase httpMethod) {
+    private static void setAuthorizationHeader(HttpUriRequestBase httpMethod) {
 
         String name = EndpointConfigManager.getAppName();
         String password = String.valueOf(EndpointConfigManager.getAppPassword());
diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.endpoint.util/src/main/java/org/wso2/carbon/identity/application/authentication/endpoint/util/client/AuthAPIServiceClient.java b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.endpoint.util/src/main/java/org/wso2/carbon/identity/application/authentication/endpoint/util/client/AuthAPIServiceClient.java
index c035ee77eef2..680c6b0e2dd4 100644
--- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.endpoint.util/src/main/java/org/wso2/carbon/identity/application/authentication/endpoint/util/client/AuthAPIServiceClient.java
+++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.endpoint.util/src/main/java/org/wso2/carbon/identity/application/authentication/endpoint/util/client/AuthAPIServiceClient.java
@@ -21,16 +21,16 @@
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpHeaders;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.HttpHeaders;
 import org.json.JSONObject;
 import org.wso2.carbon.identity.application.authentication.endpoint.util.client.exception.ServiceClientException;
 import org.wso2.carbon.identity.application.authentication.endpoint.util.client.model.AuthenticationErrorResponse;
 import org.wso2.carbon.identity.application.authentication.endpoint.util.client.model.AuthenticationResponse;
 import org.wso2.carbon.identity.application.authentication.endpoint.util.client.model.AuthenticationSuccessResponse;
+import org.wso2.carbon.utils.httpclient5.HTTPClientUtils;
 
 import java.io.BufferedReader;
 import java.io.IOException;
@@ -54,7 +54,6 @@ public class AuthAPIServiceClient {
     private static final String RESPONSE_PARAM_PROPERTIES = "properties";
 
     private String basePath;
-    private CloseableHttpClient httpClient;
 
     /**
      * Constructor to initialize service client.
@@ -63,7 +62,6 @@ public class AuthAPIServiceClient {
      */
     public AuthAPIServiceClient(String apiBasePath) {
 
-        httpClient = HttpClients.createDefault();
         basePath = apiBasePath;
     }
 
@@ -80,37 +78,43 @@ public AuthenticationResponse authenticate(String username, Object password) thr
 
         String endpointURL = basePath + "authenticate";
 
-        AuthenticationResponse authenticationResponse;
         HttpPost httpPostRequest = new HttpPost(endpointURL);
         httpPostRequest.setHeader(HttpHeaders.AUTHORIZATION, buildBasicAuthHeader(username, password));
         httpPostRequest.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
-        try (CloseableHttpResponse response = httpClient.execute(httpPostRequest)) {
 
-            int statusCode = response.getStatusLine().getStatusCode();
-            String responseString = extractResponse(response);
-            if (log.isDebugEnabled()) {
-                log.debug("Response: { status: " + response.getStatusLine().getStatusCode() + "\n data: " +
+        try (CloseableHttpClient httpClient = HTTPClientUtils.createClientWithCustomHostnameVerifier().build()) {
+            return httpClient.execute(httpPostRequest, response -> {
+
+                String responseString;
+                try {
+                    responseString = extractResponse(response);
+                } catch (ServiceClientException e) {
+                    throw new RuntimeException(e);
+                }
+                if (log.isDebugEnabled()) {
+                    log.debug("Response: { status: " + response.getCode() + "\n data: " +
                         responseString + " }");
             }
 
+            AuthenticationResponse authenticationResponse;
             JSONObject responseObj = new JSONObject(responseString);
             if (responseObj.has(RESPONSE_PARAM_TOKEN)) {
                 authenticationResponse = populateAuthenticationSuccessResponse(responseObj);
             } else {
                 authenticationResponse = populateAuthenticationErrorResponse(responseObj);
             }
-            authenticationResponse.setStatusCode(statusCode);
+            authenticationResponse.setStatusCode(response.getCode());
 
-        } catch (IOException e) {
+            return authenticationResponse;
+            });
+        } catch (RuntimeException | IOException e) {
             String msg = "Error while invoking " + endpointURL;
             log.error(msg, e);
             throw new ServiceClientException(msg, e);
         }
-
-        return authenticationResponse;
     }
 
-    private String extractResponse(CloseableHttpResponse httpResponse) throws ServiceClientException {
+    private String extractResponse(ClassicHttpResponse httpResponse) throws ServiceClientException {
 
         StringBuilder response = new StringBuilder();
         try (BufferedReader reader = new BufferedReader(
diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/pom.xml b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/pom.xml
index 84b113b8fc2a..3927eba31ec8 100644
--- a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/pom.xml
+++ b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/pom.xml
@@ -193,16 +193,6 @@
             <artifactId>gson</artifactId>
             <scope>provided</scope>
         </dependency>
-        <dependency>
-            <groupId>org.wso2.orbit.org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.httpcomponents.wso2</groupId>
-            <artifactId>httpcore</artifactId>
-            <scope>provided</scope>
-        </dependency>
         <dependency>
             <groupId>org.json.wso2</groupId>
             <artifactId>json</artifactId>
@@ -260,9 +250,12 @@
             <artifactId>org.wso2.carbon.utils</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <scope>test</scope>
+            <groupId>org.wso2.orbit.org.apache.httpcomponents</groupId>
+            <artifactId>httpcore5</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.orbit.org.apache.httpcomponents</groupId>
+            <artifactId>httpclient5</artifactId>
         </dependency>
     </dependencies>
 
@@ -290,12 +283,6 @@
                             org.apache.axis2.*; version="${axis2.osgi.version.range}",
                             org.apache.axiom.*; version="${axiom.osgi.version.range}",
 
-                            org.apache.http; version="${httpcore.version.osgi.import.range}",
-                            org.apache.http.client; version="${httpcomponents-httpclient.imp.pkg.version.range}",
-                            org.apache.http.client.methods; version="${httpcomponents-httpclient.imp.pkg.version.range}",
-                            org.apache.http.entity; version="${httpcore.version.osgi.import.range}",
-                            org.apache.http.impl.client; version="${httpcomponents-httpclient.imp.pkg.version.range}",
-
                             org.apache.commons.codec.binary; version="${commons-codec.wso2.osgi.version.range}",
                             org.apache.commons.collections; version="${commons-collections.wso2.osgi.version.range}",
                             org.apache.commons.lang; version="${commons-lang.wso2.osgi.version.range}",
diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/IdentityManagementEndpointUtil.java b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/IdentityManagementEndpointUtil.java
index e0c6f448fd4d..6ea97f19ca71 100644
--- a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/IdentityManagementEndpointUtil.java
+++ b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/IdentityManagementEndpointUtil.java
@@ -31,6 +31,9 @@
 import org.apache.cxf.Bus;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
+import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.core5.http.HttpStatus;
 import org.json.JSONArray;
 import org.json.JSONObject;
 import org.owasp.encoder.Encode;
@@ -53,14 +56,17 @@
 import org.wso2.carbon.identity.mgt.endpoint.util.client.model.RetryError;
 import org.wso2.carbon.identity.mgt.endpoint.util.client.model.User;
 import org.wso2.carbon.identity.mgt.stub.beans.VerificationBean;
+import org.wso2.carbon.utils.httpclient5.HTTPClientUtils;
 import org.wso2.securevault.SecretResolver;
 import org.wso2.securevault.SecretResolverFactory;
 import org.wso2.securevault.commons.MiscellaneousUtil;
 
+import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -1026,4 +1032,33 @@ private static void updateCookieConfig(CookieBuilder cookieBuilder, IdentityCook
 
         cookieBuilder.setSecure(cookieConfig.isSecure());
     }
+
+    /**
+     * Executes the HTTP client request and returns the response as a string.
+     *
+     * @param request The HTTP request to execute.
+     * @return The response body as a string.
+     * @throws IOException If an I/O error occurs or the response status is not SC_OK.
+     */
+    public static String getHttpClientResponseString(HttpUriRequestBase request) throws IOException {
+
+        try (CloseableHttpClient httpClient = HTTPClientUtils.createClientWithCustomHostnameVerifier().build()) {
+            return httpClient.execute(request, response -> {
+                if (response.getCode() == HttpStatus.SC_OK) {
+                    try (InputStream inputStream = response.getEntity().getContent();
+                         InputStreamReader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
+                         BufferedReader bufferedReader = new BufferedReader(reader)) {
+
+                        StringBuilder content = new StringBuilder();
+                        String line;
+                        while ((line = bufferedReader.readLine()) != null) {
+                            content.append(line);
+                        }
+                        return content.toString();
+                    }
+                }
+                return null;
+            });
+        }
+    }
 }
diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/AdminAdvisoryDataRetrievalClient.java b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/AdminAdvisoryDataRetrievalClient.java
index 57bef15fd5c2..2e474a4d0c04 100644
--- a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/AdminAdvisoryDataRetrievalClient.java
+++ b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/AdminAdvisoryDataRetrievalClient.java
@@ -18,20 +18,15 @@
 
 package org.wso2.carbon.identity.mgt.endpoint.util.client;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
 import org.json.JSONObject;
 import org.json.JSONTokener;
 import org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementEndpointUtil;
-import org.wso2.carbon.utils.HTTPClientUtils;
 
 import java.io.IOException;
-import java.io.InputStreamReader;
 
 /**
  * Client to interact with the Admin Advisory Management API.
@@ -54,23 +49,19 @@ public class AdminAdvisoryDataRetrievalClient {
      */
     public JSONObject getAdminAdvisoryBannerData(String tenant) throws AdminAdvisoryDataRetrievalClientException {
 
-        try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomVerifier().build()) {
-
+        try {
             String uri = getAdminAdvisoryBannerEndpoint(tenant);
             HttpGet request = new HttpGet(uri);
 
-            try (CloseableHttpResponse response = httpclient.execute(request)) {
-                if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-                    return new JSONObject(new JSONTokener(new InputStreamReader(response
-                            .getEntity().getContent())));
-                }
-                JSONObject defaultBanner = new JSONObject();
-                defaultBanner.put(ENABLE_BANNER, false);
-                defaultBanner.put(BANNER_CONTENT, DEFAULT_BANNER_CONTENT);
-                return defaultBanner;
-            } finally {
-                request.releaseConnection();
+            String responseString = IdentityManagementEndpointUtil.getHttpClientResponseString(request);
+
+            if (!StringUtils.isEmpty(responseString)) {
+                return new JSONObject(new JSONTokener(responseString));
             }
+            JSONObject defaultBanner = new JSONObject();
+            defaultBanner.put(ENABLE_BANNER, false);
+            defaultBanner.put(BANNER_CONTENT, DEFAULT_BANNER_CONTENT);
+            return defaultBanner;
         } catch (IOException e) {
             String msg = "Error while getting admin advisory banner preference for tenant : " + tenant;
             LOG.debug(msg, e);
diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/ApplicationDataRetrievalClient.java b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/ApplicationDataRetrievalClient.java
index 06cc5e91d7de..5c5492beecae 100644
--- a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/ApplicationDataRetrievalClient.java
+++ b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/ApplicationDataRetrievalClient.java
@@ -23,11 +23,8 @@
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase;
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
@@ -35,10 +32,8 @@
 import org.owasp.encoder.Encode;
 import org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementEndpointUtil;
 import org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementServiceUtil;
-import org.wso2.carbon.utils.HTTPClientUtils;
 
 import java.io.IOException;
-import java.io.InputStreamReader;
 import java.nio.charset.Charset;
 
 /**
@@ -68,38 +63,39 @@ public class ApplicationDataRetrievalClient {
     public String getApplicationAccessURL(String tenant, String applicationName)
             throws ApplicationDataRetrievalClientException {
 
-        try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomVerifier().build()) {
+        try {
             HttpGet request =
                     new HttpGet(getApplicationsEndpoint(tenant) + APP_FILTER +
                             Encode.forUriComponent(applicationName));
             setAuthorizationHeader(request);
 
-            try (CloseableHttpResponse response = httpclient.execute(request)) {
+            String responseString = IdentityManagementEndpointUtil.getHttpClientResponseString(request);
 
-                if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-                    JSONObject jsonResponse = new JSONObject(
-                            new JSONTokener(new InputStreamReader(response.getEntity().getContent())));
-                    JSONArray applications = jsonResponse.getJSONArray(APPLICATIONS_KEY);
-                    if (applications.length() != 1) {
-                        return StringUtils.EMPTY;
-                    }
+            if (!StringUtils.isEmpty(responseString)) {
+                JSONObject application = getSingleApplicationFromResponse(responseString);
+                if (application == null) {
+                    return StringUtils.EMPTY;
+                }
+
+                if (application.has(ACCESS_URL_KEY)) {
+                    return application.getString(ACCESS_URL_KEY);
+                }
 
-                    JSONObject application = (JSONObject) applications.get(0);
-                    if (application.has(ACCESS_URL_KEY)) {
-                        return application.getString(ACCESS_URL_KEY);
-                    }
                     /*
                     If access URL is not stored in the DB but resolved from a listener, need to get the access url by
                     invoking application get by id.
                      */
-                    if (application.has(APP_ID)) {
+                if (application.has(APP_ID)) {
+                    try {
                         return getApplicationAccessURLByAppId(tenant, application.getString(APP_ID));
+                    } catch (ApplicationDataRetrievalClientException e) {
+                        throw new RuntimeException(e);
                     }
                 }
-            } finally {
-                request.releaseConnection();
             }
-        } catch (IOException | JSONException e) {
+
+            return StringUtils.EMPTY;
+        } catch (RuntimeException | IOException e) {
             //JSONException may occur if the application don't have an access URL configured
             String msg = "Error while getting access URL of " + applicationName + " in tenant : " + tenant;
             if (log.isDebugEnabled()) {
@@ -107,7 +103,6 @@ public String getApplicationAccessURL(String tenant, String applicationName)
             }
             throw new ApplicationDataRetrievalClientException(msg, e);
         }
-        return StringUtils.EMPTY;
     }
 
     /**
@@ -121,30 +116,26 @@ public String getApplicationAccessURL(String tenant, String applicationName)
     public boolean getApplicationEnabledStatus(String tenant, String applicationName)
             throws ApplicationDataRetrievalClientException {
 
-        try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomVerifier().build()) {
+        try {
             HttpGet request =
                     new HttpGet(getApplicationsEndpoint(tenant) + APP_FILTER +
                             Encode.forUriComponent(applicationName) + APP_ENABLED_STATE_QUERY);
             setAuthorizationHeader(request);
 
-            try (CloseableHttpResponse response = httpclient.execute(request)) {
+            String responseString = IdentityManagementEndpointUtil.getHttpClientResponseString(request);
 
-                if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-                    JSONObject jsonResponse = new JSONObject(
-                            new JSONTokener(new InputStreamReader(response.getEntity().getContent())));
-                    JSONArray applications = jsonResponse.getJSONArray(APPLICATIONS_KEY);
-                    if (applications.length() != 1) {
-                        return false;
-                    }
+            if (!StringUtils.isEmpty(responseString)) {
+                JSONObject application = getSingleApplicationFromResponse(responseString);
+                if (application == null) {
+                    return false;
+                }
 
-                    JSONObject application = (JSONObject) applications.get(0);
-                    if (application.has(APP_ENABLED_STATE_KEY)) {
-                        return application.getBoolean(APP_ENABLED_STATE_KEY);
-                    }
+                if (application.has(APP_ENABLED_STATE_KEY)) {
+                    return application.getBoolean(APP_ENABLED_STATE_KEY);
                 }
-            } finally {
-                request.releaseConnection();
             }
+
+            return false;
         } catch (IOException | JSONException e) {
             String msg = "Error while getting enabled status of " + applicationName + " in tenant : " + tenant;
             if (log.isDebugEnabled()) {
@@ -152,7 +143,6 @@ public boolean getApplicationEnabledStatus(String tenant, String applicationName
             }
             throw new ApplicationDataRetrievalClientException(msg, e);
         }
-        return false;
     }
 
     /**
@@ -166,19 +156,18 @@ public boolean getApplicationEnabledStatus(String tenant, String applicationName
     public String getApplicationAccessURLByAppId(String tenant, String applicationId)
             throws ApplicationDataRetrievalClientException {
 
-        try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomVerifier().build()) {
+        try {
             HttpGet request = new HttpGet(getApplicationsEndpoint(tenant) + "/" + applicationId);
             setAuthorizationHeader(request);
 
-            try (CloseableHttpResponse response = httpclient.execute(request)) {
-                if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-                    JSONObject jsonResponse = new JSONObject(
-                            new JSONTokener(new InputStreamReader(response.getEntity().getContent())));
-                    return jsonResponse.getString(ACCESS_URL_KEY);
-                }
-            } finally {
-                request.releaseConnection();
+            String responseString = IdentityManagementEndpointUtil.getHttpClientResponseString(request);
+
+            if (!StringUtils.isEmpty(responseString)) {
+                JSONObject jsonResponse = new JSONObject(new JSONTokener(responseString));
+                return jsonResponse.getString(ACCESS_URL_KEY);
             }
+
+            return StringUtils.EMPTY;
         } catch (IOException | JSONException e) {
             //JSONException may occur if the application don't have an access URL configured
             String msg = "Error while getting access URL of " + applicationId + " in tenant : " + tenant;
@@ -187,7 +176,6 @@ public String getApplicationAccessURLByAppId(String tenant, String applicationId
             }
             throw new ApplicationDataRetrievalClientException(msg, e);
         }
-        return StringUtils.EMPTY;
     }
 
     /**
@@ -201,21 +189,19 @@ public String getApplicationAccessURLByAppId(String tenant, String applicationId
     public String getApplicationName(String tenant, String applicationId)
             throws ApplicationDataRetrievalClientException {
 
-        try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomVerifier().build()) {
+        try {
             HttpGet request =
                     new HttpGet(getApplicationsEndpoint(tenant) + "/" + applicationId);
             setAuthorizationHeader(request);
 
-            try (CloseableHttpResponse response = httpclient.execute(request)) {
+            String responseString = IdentityManagementEndpointUtil.getHttpClientResponseString(request);
 
-                if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-                    JSONObject jsonResponse = new JSONObject(
-                            new JSONTokener(new InputStreamReader(response.getEntity().getContent())));
-                    return jsonResponse.getString(APP_NAME);
-                }
-            } finally {
-                request.releaseConnection();
+            if (!StringUtils.isEmpty(responseString)) {
+                JSONObject jsonResponse = new JSONObject(new JSONTokener(responseString));
+                return jsonResponse.getString(APP_NAME);
             }
+
+            return StringUtils.EMPTY;
         } catch (IOException | JSONException e) {
             //JSONException may occur if the application don't have an access URL configured
             String msg = "Error while getting application name for " + applicationId + " in tenant : " + tenant;
@@ -224,7 +210,6 @@ public String getApplicationName(String tenant, String applicationId)
             }
             throw new ApplicationDataRetrievalClientException(msg, e);
         }
-        return StringUtils.EMPTY;
     }
 
     /**
@@ -238,28 +223,24 @@ public String getApplicationName(String tenant, String applicationId)
     public String getApplicationID(String tenant, String applicationName)
             throws ApplicationDataRetrievalClientException {
 
-        try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomVerifier().build()) {
+        try {
             HttpGet request =
                     new HttpGet(getApplicationsEndpoint(tenant) + APP_FILTER +
                             Encode.forUriComponent(applicationName));
             setAuthorizationHeader(request);
 
-            try (CloseableHttpResponse response = httpclient.execute(request)) {
-
-                if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-                    JSONObject jsonResponse = new JSONObject(
-                            new JSONTokener(new InputStreamReader(response.getEntity().getContent())));
-                    JSONArray applications = jsonResponse.getJSONArray(APPLICATIONS_KEY);
-                    if (applications.length() != 1) {
-                        return StringUtils.EMPTY;
-                    }
+            String responseString = IdentityManagementEndpointUtil.getHttpClientResponseString(request);
 
-                    JSONObject application = (JSONObject) applications.get(0);
-                    return application.getString(APP_ID);
+            if (!StringUtils.isEmpty(responseString)) {
+                JSONObject application = getSingleApplicationFromResponse(responseString);
+                if (application == null) {
+                    return StringUtils.EMPTY;
                 }
-            } finally {
-                request.releaseConnection();
+                
+                return application.getString(APP_ID);
             }
+
+            return StringUtils.EMPTY;
         } catch (IOException | JSONException e) {
             //JSONException may occur if the application don't have an access URL configured
             String msg = "Error while getting application ID for " + applicationName + " in tenant : " + tenant;
@@ -268,9 +249,25 @@ public String getApplicationID(String tenant, String applicationName)
             }
             throw new ApplicationDataRetrievalClientException(msg, e);
         }
-        return StringUtils.EMPTY;
     }
 
+    /**
+     * Parses a JSON response string and extracts a single application object if available.
+     *
+     * @param responseString JSON response string from API
+     * @return the single application JSONObject or null if not exactly one application is found
+     * @throws JSONException if parsing the JSON response fails
+     */
+    private JSONObject getSingleApplicationFromResponse(String responseString) throws JSONException {
+
+        JSONObject jsonResponse = new JSONObject(new JSONTokener(responseString));
+        JSONArray applications = jsonResponse.getJSONArray(APPLICATIONS_KEY);
+        if (applications.length() != 1) {
+            return null;
+        }
+        
+        return (JSONObject) applications.get(0);
+    }
 
     private String getApplicationsEndpoint(String tenantDomain) throws ApplicationDataRetrievalClientException {
 
@@ -286,7 +283,7 @@ private String getEndpoint(String tenantDomain, String context) throws Applicati
         }
     }
 
-    private void setAuthorizationHeader(HttpRequestBase httpMethod) {
+    private void setAuthorizationHeader(HttpUriRequestBase httpMethod) {
 
         String toEncode = IdentityManagementServiceUtil.getInstance().getAppName() + ":"
                 + String.valueOf(IdentityManagementServiceUtil.getInstance().getAppPassword());
diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/AuthenticatorDataRetrievalClient.java b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/AuthenticatorDataRetrievalClient.java
index b4269c385984..4c5693c9918b 100644
--- a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/AuthenticatorDataRetrievalClient.java
+++ b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/AuthenticatorDataRetrievalClient.java
@@ -20,22 +20,18 @@
 
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase;
 import org.json.JSONException;
 import org.json.JSONObject;
 import org.json.JSONTokener;
 import org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementEndpointUtil;
 import org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementServiceUtil;
-import org.wso2.carbon.utils.HTTPClientUtils;
 
 import java.io.IOException;
-import java.io.InputStreamReader;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
@@ -67,33 +63,28 @@ public Map<String, String> getAuthenticatorConfig(String tenant, String authenti
 
         Map<String, String> authenticatorConfig = new HashMap<>();
         String authenticatorId = base64URLEncode(authenticatorIdentifier);
-        try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomVerifier().build()) {
+        try {
             HttpGet request = new HttpGet(getAuthenticatorEndpoint(tenant) + "/" + authenticatorId);
             setAuthorizationHeader(request);
 
-            try (CloseableHttpResponse response = httpclient.execute(request)) {
+            String responseString = IdentityManagementEndpointUtil.getHttpClientResponseString(request);
 
-                if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-                    JSONObject jsonResponse = new JSONObject(
-                            new JSONTokener(new InputStreamReader(response.getEntity().getContent())));
+            if (!StringUtils.isEmpty(responseString)) {
+                JSONObject jsonResponse = new JSONObject(new JSONTokener(responseString));
 
-                    if (jsonResponse.has(IMAGE_KEY)) {
-                        // Image is an optional attribute.
-                        authenticatorConfig.put(IMAGE_KEY, jsonResponse.getString(IMAGE_KEY));
-                    }
-                    authenticatorConfig.put(DISPLAY_NAME_KEY, jsonResponse.getString(DISPLAY_NAME_KEY));
-                    authenticatorConfig.put(DEFINED_BY_KEY, jsonResponse.getString(DEFINED_BY_KEY));
+                if (jsonResponse.has(IMAGE_KEY)) {
+                    // Image is an optional attribute.
+                    authenticatorConfig.put(IMAGE_KEY, jsonResponse.getString(IMAGE_KEY));
                 }
-            } finally {
-                request.releaseConnection();
+                authenticatorConfig.put(DISPLAY_NAME_KEY, jsonResponse.getString(DISPLAY_NAME_KEY));
+                authenticatorConfig.put(DEFINED_BY_KEY, jsonResponse.getString(DEFINED_BY_KEY));
             }
+            return authenticatorConfig;
         } catch (IOException | JSONException e) {
             String msg = "Error while getting configs of " + authenticatorIdentifier + " in tenant : " + tenant;
             LOG.debug(msg, e);
             throw new AuthenticatorDataRetrievalClientException(msg, e);
         }
-
-        return authenticatorConfig;
     }
 
     public static String base64URLEncode(String value) {
@@ -114,7 +105,7 @@ private String getAuthenticatorEndpoint(String tenantDomain)
         }
     }
 
-    private void setAuthorizationHeader(HttpRequestBase httpMethod) {
+    private void setAuthorizationHeader(HttpUriRequestBase httpMethod) {
 
         String toEncode = IdentityManagementServiceUtil.getInstance().getAppName() + ":"
                 + String.valueOf(IdentityManagementServiceUtil.getInstance().getAppPassword());
diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/BrandingPreferenceRetrievalClient.java b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/BrandingPreferenceRetrievalClient.java
index 6d0e95fe77d1..ab019b877361 100644
--- a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/BrandingPreferenceRetrievalClient.java
+++ b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/BrandingPreferenceRetrievalClient.java
@@ -23,22 +23,17 @@
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.client.utils.URIBuilder;
-import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase;
+import org.apache.hc.core5.net.URIBuilder;
 import org.json.JSONObject;
 import org.json.JSONTokener;
 import org.wso2.carbon.context.PrivilegedCarbonContext;
 import org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants;
 import org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementEndpointUtil;
 import org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementServiceUtil;
-import org.wso2.carbon.utils.HTTPClientUtils;
 
 import java.io.IOException;
-import java.io.InputStreamReader;
 import java.net.URISyntaxException;
 import java.nio.charset.Charset;
 
@@ -71,7 +66,7 @@ public class BrandingPreferenceRetrievalClient {
     public JSONObject getPreference(String tenant, String type, String name, String locale)
             throws BrandingPreferenceRetrievalClientException {
 
-        try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomVerifier().build()) {
+        try {
 
             String uri = getBrandingPreferenceEndpoint(tenant);
 
@@ -107,19 +102,9 @@ public JSONObject getPreference(String tenant, String type, String name, String
             HttpGet request = new HttpGet(uri);
             setAuthorizationHeader(request);
 
-            JSONObject jsonResponse = new JSONObject();
-
-            try (CloseableHttpResponse response = httpclient.execute(request)) {
+            String responseString = IdentityManagementEndpointUtil.getHttpClientResponseString(request);
 
-                if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-                    jsonResponse = new JSONObject(
-                            new JSONTokener(new InputStreamReader(response.getEntity().getContent())));
-                }
-
-                return jsonResponse;
-            } finally {
-                request.releaseConnection();
-            }
+            return parseJsonResponse(responseString);
         } catch (IOException e) {
             String msg = "Error while getting branding preference for tenant : " + tenant;
 
@@ -145,7 +130,7 @@ public JSONObject getPreference(String tenant, String type, String name, String
     public JSONObject getCustomTextPreference(String tenant, String type, String name, String screen, String locale)
             throws BrandingPreferenceRetrievalClientException {
 
-        try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomVerifier().build()) {
+        try {
 
             String uri = getCustomTextPreferenceEndpoint(tenant);
 
@@ -182,19 +167,9 @@ public JSONObject getCustomTextPreference(String tenant, String type, String nam
             HttpGet request = new HttpGet(uri);
             setAuthorizationHeader(request);
 
-            JSONObject jsonResponse = new JSONObject();
-
-            try (CloseableHttpResponse response = httpclient.execute(request)) {
-
-                if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-                    jsonResponse = new JSONObject(
-                            new JSONTokener(new InputStreamReader(response.getEntity().getContent())));
-                }
+            String responseString = IdentityManagementEndpointUtil.getHttpClientResponseString(request);
 
-                return jsonResponse;
-            } finally {
-                request.releaseConnection();
-            }
+            return parseJsonResponse(responseString);
         } catch (IOException e) {
             String msg = "Error while getting custom text preference for tenant : " + tenant;
 
@@ -205,6 +180,21 @@ public JSONObject getCustomTextPreference(String tenant, String type, String nam
         }
     }
 
+    /**
+     * Parse a string response to a JSONObject.
+     *
+     * @param responseString The string to parse
+     * @return A JSONObject containing the parsed data or an empty JSONObject if the string is empty
+     */
+    private JSONObject parseJsonResponse(String responseString) {
+
+        JSONObject jsonResponse = new JSONObject();
+        if (!StringUtils.isEmpty(responseString)) {
+            jsonResponse = new JSONObject(new JSONTokener(responseString));
+        }
+        return jsonResponse;
+    }
+
     /**
      * Get the tenant branding preferences endpoint.
      *
@@ -263,7 +253,7 @@ private String getEndpoint(String tenantDomain, String context)
      *
      * @param httpMethod HTTP request method.
      */
-    private void setAuthorizationHeader(HttpRequestBase httpMethod) {
+    private void setAuthorizationHeader(HttpUriRequestBase httpMethod) {
 
         String toEncode = IdentityManagementServiceUtil.getInstance().getAppName() + ":"
                 + String.valueOf(IdentityManagementServiceUtil.getInstance().getAppPassword());
diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/CommonDataRetrievalClient.java b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/CommonDataRetrievalClient.java
index cf3ff9294dea..46ff4f289e20 100644
--- a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/CommonDataRetrievalClient.java
+++ b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/CommonDataRetrievalClient.java
@@ -20,24 +20,18 @@
 
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase;
 import org.json.JSONObject;
 import org.json.JSONTokener;
 import org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementEndpointUtil;
 import org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementServiceUtil;
-import org.wso2.carbon.utils.HTTPClientUtils;
 
 import java.io.IOException;
-import java.io.InputStreamReader;
 import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
 
 /**
  * Client which can retrieve data from given endpoint.
@@ -58,32 +52,21 @@ public boolean checkBooleanProperty(String apiContextPath, String tenantDomain,
                                         boolean defaultValue, boolean isEndpointTenantAware)
             throws CommonDataRetrievalClientException {
 
-        try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomVerifier().build()) {
+        try {
 
             String uri = getEndpoint(tenantDomain, apiContextPath, isEndpointTenantAware);
             HttpGet get = new HttpGet(uri);
             setAuthorizationHeader(get);
 
-            try (CloseableHttpResponse response = httpclient.execute(get)) {
+            String responseString = IdentityManagementEndpointUtil.getHttpClientResponseString(get);
 
-                if (log.isDebugEnabled()) {
-                    log.debug("Response code for the checkProperty call in tenant " + tenantDomain
-                            + "for api " + apiContextPath + " is " + response.getStatusLine().getStatusCode());
-                }
-                if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-                    HttpEntity entity = response.getEntity();
-                    if (entity != null) {
-                        JSONObject jsonResponse = new JSONObject(new JSONTokener(new InputStreamReader(
-                                response.getEntity().getContent(), StandardCharsets.UTF_8)));
-                        if (jsonResponse.has(propertyName)) {
-                            return jsonResponse.getBoolean(propertyName);
-                        }
-                    }
+            if (!StringUtils.isEmpty(responseString)) {
+                JSONObject jsonResponse = new JSONObject(new JSONTokener(responseString));
+                if (jsonResponse.has(propertyName)) {
+                    return jsonResponse.getBoolean(propertyName);
                 }
-                return defaultValue;
-            } finally {
-                get.releaseConnection();
             }
+            return defaultValue;
         } catch (IOException e) {
             // Logging and throwing since this is a client.
             String msg = "Error while checking property in tenant " + tenantDomain + "for api " + apiContextPath;
@@ -118,7 +101,7 @@ private String getEndpoint(String tenantDomain, String context, boolean isEndpoi
      *
      * @param httpMethod HTTP request method.
      */
-    private void setAuthorizationHeader(HttpRequestBase httpMethod) {
+    private void setAuthorizationHeader(HttpUriRequestBase httpMethod) {
 
         String toEncode = IdentityManagementServiceUtil.getInstance().getAppName() + ":"
                 + String.valueOf(IdentityManagementServiceUtil.getInstance().getAppPassword());
diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/ConfiguredAuthenticatorsRetrievalClient.java b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/ConfiguredAuthenticatorsRetrievalClient.java
index 4cd085106ab7..b95b43d5f6ae 100644
--- a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/ConfiguredAuthenticatorsRetrievalClient.java
+++ b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/ConfiguredAuthenticatorsRetrievalClient.java
@@ -20,23 +20,19 @@
 
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase;
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONTokener;
 import org.owasp.encoder.Encode;
 import org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementEndpointUtil;
 import org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementServiceUtil;
-import org.wso2.carbon.utils.HTTPClientUtils;
 
 import java.io.IOException;
-import java.io.InputStreamReader;
 import java.nio.charset.Charset;
 
 /**
@@ -60,22 +56,18 @@ public class ConfiguredAuthenticatorsRetrievalClient {
     public JSONArray getConfiguredAuthenticators(String applicationId, String tenantDomain)
             throws ConfiguredAuthenticatorsRetrievalClientException {
 
-        try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomVerifier().build()) {
+        try {
             HttpGet request =
                     new HttpGet(getApplicationsEndpoint(tenantDomain) + "/" + Encode.forUriComponent(applicationId) +
                             AUTHENTICATORS);
             setAuthorizationHeader(request);
 
-            try (CloseableHttpResponse response = httpclient.execute(request)) {
+            String responseString = IdentityManagementEndpointUtil.getHttpClientResponseString(request);
 
-                if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-                    JSONArray jsonResponse = new JSONArray(
-                            new JSONTokener(new InputStreamReader(response.getEntity().getContent())));
-                    return jsonResponse;
-                }
-            } finally {
-                request.releaseConnection();
+            if (!StringUtils.isEmpty(responseString)) {
+                return new JSONArray(new JSONTokener(responseString));
             }
+            return null;
         } catch (IOException | JSONException e) {
             //JSONException may occur if the application don't have an access URL configured
             String msg = "Error while getting authenticators configured for application Id: " + applicationId;
@@ -84,7 +76,6 @@ public JSONArray getConfiguredAuthenticators(String applicationId, String tenant
             }
             throw new ConfiguredAuthenticatorsRetrievalClientException(msg, e);
         }
-        return null;
     }
 
     private String getApplicationsEndpoint(String tenantDomain) throws ConfiguredAuthenticatorsRetrievalClientException {
@@ -103,7 +94,7 @@ private String getEndpoint(String tenantDomain, String context)
         }
     }
 
-    private void setAuthorizationHeader(HttpRequestBase httpMethod) {
+    private void setAuthorizationHeader(HttpUriRequestBase httpMethod) {
 
         String toEncode = IdentityManagementServiceUtil.getInstance().getAppName() + ":"
                 + String.valueOf(IdentityManagementServiceUtil.getInstance().getAppPassword());
diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/IdentityProviderDataRetrievalClient.java b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/IdentityProviderDataRetrievalClient.java
index f7b35d5ed7df..a3dc0bd0bdd2 100644
--- a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/IdentityProviderDataRetrievalClient.java
+++ b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/IdentityProviderDataRetrievalClient.java
@@ -24,11 +24,8 @@
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase;
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
@@ -36,10 +33,8 @@
 import org.owasp.encoder.Encode;
 import org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementEndpointUtil;
 import org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementServiceUtil;
-import org.wso2.carbon.utils.HTTPClientUtils;
 
 import java.io.IOException;
-import java.io.InputStreamReader;
 import java.nio.charset.Charset;
 import java.util.HashMap;
 import java.util.List;
@@ -76,29 +71,26 @@ public class IdentityProviderDataRetrievalClient {
     public String getIdPImage(String tenant, String idpName)
             throws IdentityProviderDataRetrievalClientException {
 
-        try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomVerifier().build()) {
+        try {
             HttpGet request = new HttpGet(getIdPEndpoint(tenant) + IDP_FILTER +
                             Encode.forUriComponent(idpName));
             setAuthorizationHeader(request);
 
-            try (CloseableHttpResponse response = httpclient.execute(request)) {
+            String responseString = IdentityManagementEndpointUtil.getHttpClientResponseString(request);
 
-                if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-                    JSONObject jsonResponse = new JSONObject(
-                            new JSONTokener(new InputStreamReader(response.getEntity().getContent())));
-                    JSONArray idps = jsonResponse.getJSONArray(IDP_KEY);
+            if (!StringUtils.isEmpty(responseString)) {
+                JSONObject jsonResponse = new JSONObject(new JSONTokener(responseString));
+                JSONArray idps = jsonResponse.getJSONArray(IDP_KEY);
 
-                    if (idps.length() != 1) {
-                        return StringUtils.EMPTY;
-                    }
+                if (idps.length() != 1) {
+                    return StringUtils.EMPTY;
+                }
 
-                    JSONObject idp = (JSONObject) idps.get(0);
+                JSONObject idp = (JSONObject) idps.get(0);
 
-                    return idp.getString(IMAGE_KEY);
-                }
-            } finally {
-                request.releaseConnection();
+                return idp.getString(IMAGE_KEY);
             }
+            return StringUtils.EMPTY;
         } catch (IOException | JSONException e) {
             String msg = "Error while getting image of " + idpName + " in tenant : " + tenant;
 
@@ -108,8 +100,6 @@ public String getIdPImage(String tenant, String idpName)
 
             throw new IdentityProviderDataRetrievalClientException(msg, e);
         }
-
-        return StringUtils.EMPTY;
     }
 
     /**
@@ -214,24 +204,21 @@ public Map<String, String> getFederatedIdpConfigs(String tenant, String idpCode,
      */
     private JSONObject executePath(String tenant, String path) throws IdentityProviderDataRetrievalClientException {
 
-        try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomVerifier().build()) {
+        try {
             String url = getEndpoint(tenant, path);
             HttpGet httpGet = new HttpGet(url);
             setAuthorizationHeader(httpGet);
 
-            try (CloseableHttpResponse response = httpclient.execute(httpGet)) {
-                if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-                    return new JSONObject(
-                            new JSONTokener(new InputStreamReader(response.getEntity().getContent())));
-                }
-            } finally {
-                httpGet.releaseConnection();
+            String responseString = IdentityManagementEndpointUtil.getHttpClientResponseString(httpGet);
+
+            if (!StringUtils.isEmpty(responseString)) {
+                return new JSONObject(new JSONTokener(responseString));
             }
+            return null;
         } catch (IdentityProviderDataRetrievalClientException | IOException e) {
             throw new IdentityProviderDataRetrievalClientException(
                     "Error while executing the path " + path + " in tenant : " + tenant, e);
         }
-        return null;
     }
 
     /**
@@ -270,7 +257,7 @@ private String getEndpoint(String tenantDomain, String context)
      *
      * @param httpMethod HTTP request method.
      */
-    private void setAuthorizationHeader(HttpRequestBase httpMethod) {
+    private void setAuthorizationHeader(HttpUriRequestBase httpMethod) {
 
         String toEncode = IdentityManagementServiceUtil.getInstance().getAppName() + ":"
                 + String.valueOf(IdentityManagementServiceUtil.getInstance().getAppPassword());
diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/OrganizationDiscoveryConfigDataRetrievalClient.java b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/OrganizationDiscoveryConfigDataRetrievalClient.java
index 59ecda3de2f7..69f3d2fc145a 100644
--- a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/OrganizationDiscoveryConfigDataRetrievalClient.java
+++ b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/OrganizationDiscoveryConfigDataRetrievalClient.java
@@ -19,20 +19,16 @@
 package org.wso2.carbon.identity.mgt.endpoint.util.client;
 
 import org.apache.commons.codec.binary.Base64;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.commons.lang.StringUtils;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase;
 import org.json.JSONArray;
 import org.json.JSONObject;
 import org.json.JSONTokener;
 import org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementEndpointUtil;
 import org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementServiceUtil;
-import org.wso2.carbon.utils.HTTPClientUtils;
 
 import java.io.IOException;
-import java.io.InputStreamReader;
 import java.nio.charset.Charset;
 import java.util.HashMap;
 import java.util.Map;
@@ -63,27 +59,24 @@ public Map<String, String> getDiscoveryConfiguration(String tenantDomain)
 
         Map<String, String> organizationDiscoveryConfig = new HashMap<>();
 
-        try (CloseableHttpClient httpClient = HTTPClientUtils.createClientWithCustomVerifier().build()) {
+        try {
             HttpGet request = new HttpGet(getOrganizationDiscoveryConfigEndpoint(tenantDomain));
             setAuthorizationHeader(request);
 
-            try (CloseableHttpResponse httpResponse = httpClient.execute(request)) {
-                if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-                    JSONObject configObject = new JSONObject(new JSONTokener(new InputStreamReader(
-                            httpResponse.getEntity().getContent())));
-
-                    if (configObject.has(PROPERTIES) && configObject.get(PROPERTIES) instanceof JSONArray) {
-                        JSONArray properties = configObject.getJSONArray(PROPERTIES);
-                        for (int i = 0; i < properties.length(); i++) {
-                            JSONObject property = properties.getJSONObject(i);
-                            organizationDiscoveryConfig.put(property.getString(KEY), property.getString(VALUE));
-                        }
+            String responseString = IdentityManagementEndpointUtil.getHttpClientResponseString(request);
+
+            if (!StringUtils.isEmpty(responseString)) {
+                JSONObject configObject = new JSONObject(new JSONTokener(responseString));
+
+                if (configObject.has(PROPERTIES) && configObject.get(PROPERTIES) instanceof JSONArray) {
+                    JSONArray properties = configObject.getJSONArray(PROPERTIES);
+                    for (int i = 0; i < properties.length(); i++) {
+                        JSONObject property = properties.getJSONObject(i);
+                        organizationDiscoveryConfig.put(property.getString(KEY), property.getString(VALUE));
                     }
                 }
-                return organizationDiscoveryConfig;
-            } finally {
-                request.releaseConnection();
             }
+            return organizationDiscoveryConfig;
         } catch (IOException e) {
             throw new OrganizationDiscoveryConfigDataRetrievalClientException("Error while retrieving organization " +
                     "discovery configuration for tenant: " + tenantDomain, e);
@@ -102,7 +95,7 @@ private String getOrganizationDiscoveryConfigEndpoint(String tenantDomain)
         }
     }
 
-    private void setAuthorizationHeader(HttpRequestBase httpMethod) {
+    private void setAuthorizationHeader(HttpUriRequestBase httpMethod) {
 
         String toEncode = IdentityManagementServiceUtil.getInstance().getAppName() + ":"
                 + String.valueOf(IdentityManagementServiceUtil.getInstance().getAppPassword());
diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/PreferenceRetrievalClient.java b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/PreferenceRetrievalClient.java
index e2b4cfa2038f..e2dfe93fc6bc 100644
--- a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/PreferenceRetrievalClient.java
+++ b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/PreferenceRetrievalClient.java
@@ -23,24 +23,21 @@
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.json.JSONArray;
 import org.json.JSONObject;
 import org.json.JSONTokener;
 import org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementEndpointUtil;
 import org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementServiceUtil;
 import org.wso2.carbon.idp.mgt.util.IdPManagementConstants;
-import org.wso2.carbon.utils.HTTPClientUtils;
+import org.wso2.carbon.utils.httpclient5.HTTPClientUtils;
 
 import java.io.IOException;
-import java.io.InputStreamReader;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
@@ -402,59 +399,55 @@ public Optional<String> getPropertyValue(String tenant, String governanceDomain,
                                              String propertyName)
             throws PreferenceRetrievalClientException {
 
-        try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomVerifier().build()) {
+        try {
             String endpoint = getUserGovernanceEndpoint(tenant);
             HttpGet get = new HttpGet(endpoint);
             setAuthorizationHeader(get);
 
-            String governanceId = null;
-            try (CloseableHttpResponse response = httpclient.execute(get)) {
-
-                if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-                    JSONArray jsonResponse = new JSONArray(
-                            new JSONTokener(new InputStreamReader(response.getEntity().getContent())));
-                    for (int itemIndex = 0, totalObject = jsonResponse.length();
-                         itemIndex < totalObject; itemIndex++) {
-                        JSONObject config = jsonResponse.getJSONObject(itemIndex);
-                        if (StringUtils.equalsIgnoreCase(
-                                jsonResponse.getJSONObject(itemIndex).getString(PROPERTY_NAME), governanceDomain)) {
-                            governanceId = config.getString(PROPERTY_ID);
-                            break;
-                        }
+            String responseStringGet = IdentityManagementEndpointUtil.getHttpClientResponseString(get);
+
+            String governanceId = StringUtils.EMPTY;
+
+            if (!StringUtils.isEmpty(responseStringGet)) {
+                JSONArray jsonResponse = new JSONArray(new JSONTokener(responseStringGet));
+                for (int itemIndex = 0, totalObject = jsonResponse.length();
+                     itemIndex < totalObject; itemIndex++) {
+                    JSONObject config = jsonResponse.getJSONObject(itemIndex);
+                    if (StringUtils.equalsIgnoreCase(
+                            jsonResponse.getJSONObject(itemIndex).getString(PROPERTY_NAME), governanceDomain)) {
+                        governanceId = config.getString(PROPERTY_ID);
+                        break;
                     }
                 }
-            } finally {
-                get.releaseConnection();
             }
 
             endpoint = endpoint + "/" + governanceId;
             HttpGet getConnectorConfig = new HttpGet(endpoint);
             setAuthorizationHeader(getConnectorConfig);
 
-            try (CloseableHttpResponse response = httpclient.execute(getConnectorConfig)) {
-
-                if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-                    JSONObject jsonResponse = new JSONObject(
-                            new JSONTokener(new InputStreamReader(response.getEntity().getContent())));
-                    JSONArray connectorArray = jsonResponse.getJSONArray(CONNECTORS);
-                    for (int itemIndex = 0, totalObject = connectorArray.length();
-                         itemIndex < totalObject; itemIndex++) {
-                        JSONObject config = connectorArray.getJSONObject(itemIndex);
-                        if (StringUtils.equalsIgnoreCase(config.getString(PROPERTY_NAME), connectorName)) {
-                            JSONArray responseProperties = config.getJSONArray(PROPERTIES);
-                            for (int propIndex = 0, totalProp = responseProperties.length();
-                                 propIndex < totalProp; propIndex++) {
-                                JSONObject property = responseProperties.getJSONObject(propIndex);
-                                if (StringUtils.equalsIgnoreCase(property.getString(PROPERTY_NAME), propertyName)) {
-                                    return Optional.ofNullable(property.getString(PROPERTY_VALUE));
-                                }
+            String responseStringGetConnectorConfig =
+                    IdentityManagementEndpointUtil.getHttpClientResponseString(getConnectorConfig);
+
+            if (!StringUtils.isEmpty(responseStringGetConnectorConfig)) {
+                JSONObject jsonResponse = new JSONObject(
+                        new JSONTokener(responseStringGetConnectorConfig));
+                JSONArray connectorArray = jsonResponse.getJSONArray(CONNECTORS);
+                for (int itemIndex = 0, totalObject = connectorArray.length();
+                     itemIndex < totalObject; itemIndex++) {
+                    JSONObject config = connectorArray.getJSONObject(itemIndex);
+                    if (StringUtils.equalsIgnoreCase(config.getString(PROPERTY_NAME), connectorName)) {
+                        JSONArray responseProperties = config.getJSONArray(PROPERTIES);
+                        for (int propIndex = 0, totalProp = responseProperties.length();
+                             propIndex < totalProp; propIndex++) {
+                            JSONObject property = responseProperties.getJSONObject(propIndex);
+                            if (StringUtils.equalsIgnoreCase(property.getString(PROPERTY_NAME), propertyName)) {
+                                return Optional.ofNullable(property.getString(PROPERTY_VALUE));
                             }
                         }
                     }
                 }
-            } finally {
-                get.releaseConnection();
             }
+            return Optional.empty();
 
         } catch (IOException e) {
             // Logging and throwing since this is a client.
@@ -463,7 +456,6 @@ public Optional<String> getPropertyValue(String tenant, String governanceDomain,
             log.debug(msg, e);
             throw new PreferenceRetrievalClientException(msg, e);
         }
-        return Optional.empty();
     }
 
     /**
@@ -479,7 +471,7 @@ public Optional<String> getPropertyValue(String tenant, String governanceDomain,
     public boolean checkPreference(String tenant, String connectorName, String propertyName, boolean defaultValue)
             throws PreferenceRetrievalClientException {
 
-        try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomVerifier().build()) {
+        try {
             JSONArray main = new JSONArray();
             JSONObject preference = new JSONObject();
             preference.put(CONNECTOR_NAME, connectorName);
@@ -490,28 +482,24 @@ public boolean checkPreference(String tenant, String connectorName, String prope
             HttpPost post = new HttpPost(getUserGovernancePreferenceEndpoint(tenant));
             setAuthorizationHeader(post);
             post.setEntity(new StringEntity(main.toString(), ContentType.create(HTTPConstants
-                    .MEDIA_TYPE_APPLICATION_JSON, Charset.forName(StandardCharsets.UTF_8.name()))));
-
-            try (CloseableHttpResponse response = httpclient.execute(post)) {
-
-                if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-                    JSONArray jsonResponse = new JSONArray(
-                            new JSONTokener(new InputStreamReader(response.getEntity().getContent())));
-                    JSONObject connector = (JSONObject) jsonResponse.get(0);
-                    JSONArray responseProperties = connector.getJSONArray(PROPERTIES);
-                    for (int itemIndex = 0, totalObject = responseProperties.length();
-                         itemIndex < totalObject; itemIndex++) {
-                        JSONObject config = responseProperties.getJSONObject(itemIndex);
-                        if (StringUtils.equalsIgnoreCase(
-                                responseProperties.getJSONObject(itemIndex).getString(PROPERTY_NAME), propertyName)) {
-                            return Boolean.valueOf(config.getString(PROPERTY_VALUE));
-                        }
+                    .MEDIA_TYPE_APPLICATION_JSON, StandardCharsets.UTF_8)));
+
+            String responseString = IdentityManagementEndpointUtil.getHttpClientResponseString(post);
+
+            if (!StringUtils.isEmpty(responseString)) {
+                JSONArray jsonResponse = new JSONArray(new JSONTokener(responseString));
+                JSONObject connector = (JSONObject) jsonResponse.get(0);
+                JSONArray responseProperties = connector.getJSONArray(PROPERTIES);
+                for (int itemIndex = 0, totalObject = responseProperties.length();
+                     itemIndex < totalObject; itemIndex++) {
+                    JSONObject config = responseProperties.getJSONObject(itemIndex);
+                    if (StringUtils.equalsIgnoreCase(
+                            responseProperties.getJSONObject(itemIndex).getString(PROPERTY_NAME), propertyName)) {
+                        return Boolean.valueOf(config.getString(PROPERTY_VALUE));
                     }
                 }
-                return defaultValue;
-            } finally {
-                post.releaseConnection();
             }
+            return defaultValue;
         } catch (IOException e) {
             // Logging and throwing since this is a client.
             String msg = "Error while checking preference for connector : " + connectorName + " in tenant : " + tenant;
@@ -534,7 +522,7 @@ public boolean checkPreference(String tenant, String connectorName, String prope
     public boolean checkMultiplePreference(String tenant, String connectorName, List<String> propertyNames)
             throws PreferenceRetrievalClientException {
 
-        try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomVerifier().build()) {
+        try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomHostnameVerifier().build()) {
             JSONArray requestBody = new JSONArray();
             JSONObject preference = new JSONObject();
             preference.put(CONNECTOR_NAME, connectorName);
@@ -549,25 +537,21 @@ public boolean checkMultiplePreference(String tenant, String connectorName, List
             post.setEntity(new StringEntity(requestBody.toString(), ContentType.create(HTTPConstants
                     .MEDIA_TYPE_APPLICATION_JSON, Charset.forName(StandardCharsets.UTF_8.name()))));
 
-            try (CloseableHttpResponse response = httpclient.execute(post)) {
-
-                if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-                    JSONArray jsonResponse = new JSONArray(
-                            new JSONTokener(new InputStreamReader(response.getEntity().getContent())));
-                    JSONObject connector = (JSONObject) jsonResponse.get(0);
-                    JSONArray responseProperties = connector.getJSONArray(PROPERTIES);
-                    for (int itemIndex = 0, totalObject = responseProperties.length(); itemIndex < totalObject; itemIndex++) {
-                        JSONObject config = responseProperties.getJSONObject(itemIndex);
-                        if (Boolean.valueOf(config.getString(PROPERTY_VALUE))) {
-                            return true;
-                        }
+            String responseString = IdentityManagementEndpointUtil.getHttpClientResponseString(post);
+
+            if (!StringUtils.isEmpty(responseString)) {
+                JSONArray jsonResponse = new JSONArray(new JSONTokener(responseString));
+                JSONObject connector = (JSONObject) jsonResponse.get(0);
+                JSONArray responseProperties = connector.getJSONArray(PROPERTIES);
+                for (int itemIndex = 0, totalObject = responseProperties.length(); itemIndex < totalObject; itemIndex++) {
+                    JSONObject config = responseProperties.getJSONObject(itemIndex);
+                    if (Boolean.valueOf(config.getString(PROPERTY_VALUE))) {
+                        return true;
                     }
-                    return false;
                 }
-                return false;
-            } finally {
-                post.releaseConnection();
             }
+
+            return false;
         } catch (IOException e) {
             // Logging and throwing since this is a client.
             String msg = "Error while check preference for connector : " + connectorName + " in tenant : " + tenant;
@@ -597,7 +581,7 @@ private String getEndpoint(String tenantDomain, String context) throws Preferenc
         }
     }
 
-    private void setAuthorizationHeader(HttpRequestBase httpMethod) {
+    private void setAuthorizationHeader(HttpUriRequestBase httpMethod) {
 
         String toEncode = IdentityManagementServiceUtil.getInstance().getAppName() + ":"
                 + String.valueOf(IdentityManagementServiceUtil.getInstance().getAppPassword());
diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/SelfRegistrationMgtClient.java b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/SelfRegistrationMgtClient.java
index 43c5973b3390..c278fbe55e5b 100644
--- a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/SelfRegistrationMgtClient.java
+++ b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/SelfRegistrationMgtClient.java
@@ -25,14 +25,13 @@
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.json.JSONArray;
 import org.json.JSONObject;
 import org.json.JSONTokener;
@@ -40,10 +39,11 @@
 import org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementEndpointUtil;
 import org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementServiceUtil;
 import org.wso2.carbon.identity.mgt.endpoint.util.client.model.User;
-import org.wso2.carbon.utils.HTTPClientUtils;
+import org.wso2.carbon.utils.httpclient5.HTTPClientUtils;
 
 import java.io.BufferedReader;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
@@ -155,34 +155,14 @@ private String getEndpoint(String tenantDomain, String context) throws SelfRegis
 
     private String executeGet(String url) throws SelfRegistrationMgtClientException, IOException {
 
-        boolean isDebugEnabled = log.isDebugEnabled();
-        try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomVerifier().build()) {
+        HttpGet httpGet = new HttpGet(url);
+        setAuthorizationHeader(httpGet);
 
-            HttpGet httpGet = new HttpGet(url);
-            setAuthorizationHeader(httpGet);
-
-            try (CloseableHttpResponse response = httpclient.execute(httpGet)) {
-
-                if (isDebugEnabled) {
-                    log.debug("HTTP status " + response.getStatusLine().getStatusCode() + " when invoking GET for URL: "
-                            + url);
-                }
-                if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-                    BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
-                    String inputLine;
-                    StringBuilder responseString = new StringBuilder();
-
-                    while ((inputLine = reader.readLine()) != null) {
-                        responseString.append(inputLine);
-                    }
-                    return responseString.toString();
-                } else {
-                    throw new SelfRegistrationMgtClientException("Error while retrieving data from " + url + ". " +
-                            "Found http status " + response.getStatusLine());
-                }
-            } finally {
-                httpGet.releaseConnection();
-            }
+        try {
+            return IdentityManagementEndpointUtil.getHttpClientResponseString(httpGet);
+        } catch (RuntimeException e) {
+            throw new SelfRegistrationMgtClientException("Error while retrieving data from " + url + ". " +
+                    "Found http status " + e.getMessage());
         }
     }
 
@@ -254,14 +234,15 @@ private JSONObject checkUserNameValidityInternal(User user, boolean skipSignUpCh
                     + ". SkipSignUpCheck flag is set to " + skipSignUpCheck);
         }
 
-        try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomVerifier().build()) {
+        try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomHostnameVerifier().build()) {
             JSONObject userObject = new JSONObject();
             userObject.put(USERNAME, user.getUsername());
 
             JSONArray properties = new JSONArray();
             JSONObject property = new JSONObject();
             property.put(
-                    IdentityManagementEndpointConstants.KEY, IdentityManagementEndpointConstants.SKIP_SIGN_UP_ENABLE_CHECK);
+                    IdentityManagementEndpointConstants.KEY,
+                    IdentityManagementEndpointConstants.SKIP_SIGN_UP_ENABLE_CHECK);
             property.put(IdentityManagementEndpointConstants.VALUE, skipSignUpCheck);
             properties.put(property);
 
@@ -289,27 +270,43 @@ private JSONObject checkUserNameValidityInternal(User user, boolean skipSignUpCh
             post.setEntity(new StringEntity(userObject.toString(), ContentType.create(HTTPConstants
                     .MEDIA_TYPE_APPLICATION_JSON, Charset.forName(StandardCharsets.UTF_8.name()))));
 
-            try (CloseableHttpResponse response = httpclient.execute(post)) {
+            try {
+                String[] responseContent = httpclient.execute(post, response -> {
+                    if (log.isDebugEnabled()) {
+                        log.debug("HTTP status " + response.getCode() + " when validating username: "
+                                + user.getUsername());
+                    }
 
-                if (log.isDebugEnabled()) {
-                    log.debug("HTTP status " + response.getStatusLine().getStatusCode() + " when validating username: "
-                            + user.getUsername());
-                }
+                    int statusCode = response.getCode();
+
+                    try (InputStream inputStream = response.getEntity().getContent();
+                         InputStreamReader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
+                         BufferedReader bufferedReader = new BufferedReader(reader)) {
+                        StringBuilder content = new StringBuilder();
+                        String line;
+                        while ((line = bufferedReader.readLine()) != null) {
+                            content.append(line);
+                        }
+                        return new String[]{String.valueOf(statusCode), content.toString()};
+                    }
+                });
 
-                if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK ||
-                        response.getStatusLine().getStatusCode() == HttpStatus.SC_BAD_REQUEST) {
-                    JSONObject jsonResponse = new JSONObject(
-                            new JSONTokener(new InputStreamReader(response.getEntity().getContent())));
+                int statusCode = Integer.parseInt(responseContent[0]);
+                String responseString = responseContent[1];
+
+                if (statusCode == HttpStatus.SC_OK ||
+                        statusCode == HttpStatus.SC_BAD_REQUEST) {
+                    JSONObject jsonResponse = new JSONObject(new JSONTokener(responseString));
                     if (log.isDebugEnabled()) {
-                        log.debug("Username validation response: " + jsonResponse.toString(2) + " for username: " + user
-                                .getUsername());
+                        log.debug("Username validation response: " + jsonResponse.toString(2) +
+                                " for username: " + user.getUsername());
                     }
                     // Adding "code" attribute since in 200 OK instances, we're getting only statusCode
-                    if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK && jsonResponse.has(STATUS_CODE)) {
+                    if (statusCode == HttpStatus.SC_OK && jsonResponse.has(STATUS_CODE)) {
                         if (jsonResponse.has(CODE)) {
                             if (log.isDebugEnabled()) {
-                                log.debug("Trying to add code attribute in a success instance but the attribute " +
-                                        "already exists with the value: " + jsonResponse.get(CODE));
+                                log.debug("Trying to add code attribute in a success instance but the " +
+                                        "attribute already exists with the value: " + jsonResponse.get(CODE));
                             }
                         } else {
                             jsonResponse.put(CODE, jsonResponse.get(STATUS_CODE));
@@ -318,9 +315,8 @@ private JSONObject checkUserNameValidityInternal(User user, boolean skipSignUpCh
                     return jsonResponse;
                 } else {
                     // Handle invalid tenant domain error thrown by the TenantContextRewriteValve.
-                    if (response.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_FOUND) {
-                        JSONObject jsonResponse = new JSONObject(
-                                new JSONTokener(new InputStreamReader(response.getEntity().getContent())));
+                    if (statusCode == HttpStatus.SC_NOT_FOUND) {
+                        JSONObject jsonResponse = new JSONObject(new JSONTokener(responseString));
                         String content = null;
                         if (jsonResponse.get("message") != null) {
                             content = (String) jsonResponse.get("message");
@@ -334,15 +330,14 @@ private JSONObject checkUserNameValidityInternal(User user, boolean skipSignUpCh
                     }
                     // Logging and throwing since this is a client
                     if (log.isDebugEnabled()) {
-                        log.debug("Unexpected response code found: " + response.getStatusLine().getStatusCode()
+                        log.debug("Unexpected response code found: " + statusCode
                                 + " when validating username: " + user.getUsername());
                     }
-                    throw new SelfRegistrationMgtClientException("Error while checking username validity for user : "
-                            + user.getUsername());
+                    throw new RuntimeException();
                 }
-
-            } finally {
-                post.releaseConnection();
+            } catch (RuntimeException e) {
+                throw new SelfRegistrationMgtClientException("Error while checking username validity for user : "
+                        + user.getUsername());
             }
         } catch (IOException e) {
             // Logging and throwing since this is a client.
@@ -359,7 +354,7 @@ private JSONObject checkUserNameValidityInternal(User user, boolean skipSignUpCh
      *
      * @param httpMethod method which wants to add Authorization header
      */
-    private void setAuthorizationHeader(HttpRequestBase httpMethod) {
+    private void setAuthorizationHeader(HttpUriRequestBase httpMethod) {
 
         String toEncode = IdentityManagementServiceUtil.getInstance().getAppName() + ":"
                 + String.valueOf(IdentityManagementServiceUtil.getInstance().getAppPassword());
diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/ValidationConfigurationRetrievalClient.java b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/ValidationConfigurationRetrievalClient.java
index a450e36ca55f..5ae78fca79dc 100644
--- a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/ValidationConfigurationRetrievalClient.java
+++ b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/ValidationConfigurationRetrievalClient.java
@@ -20,23 +20,19 @@
 
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase;
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
 import org.json.JSONTokener;
 import org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementEndpointUtil;
 import org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementServiceUtil;
-import org.wso2.carbon.utils.HTTPClientUtils;
 
 import java.io.IOException;
-import java.io.InputStreamReader;
 import java.nio.charset.Charset;
 
 /**
@@ -77,20 +73,16 @@ public class ValidationConfigurationRetrievalClient {
     public JSONArray getConfigurations(String tenantDomain)
             throws ValidationConfigurationRetrievalClientException {
 
-        try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomVerifier().build()) {
+        try {
             HttpGet request = new HttpGet(getValidationMgtEndpoint(tenantDomain));
             setAuthorizationHeader(request);
 
-            try (CloseableHttpResponse response = httpclient.execute(request)) {
+            String responseString = IdentityManagementEndpointUtil.getHttpClientResponseString(request);
 
-                if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-                    JSONArray jsonResponse = new JSONArray(
-                            new JSONTokener(new InputStreamReader(response.getEntity().getContent())));
-                    return jsonResponse;
-                }
-            } finally {
-                request.releaseConnection();
+            if (!StringUtils.isEmpty(responseString)) {
+                return new JSONArray(new JSONTokener(responseString));
             }
+            return null;
         } catch (IOException | JSONException e) {
             //JSONException may occur if the application don't have an access URL configured
             String msg = "Error while getting validation configurations for tenant: " + tenantDomain;
@@ -99,7 +91,6 @@ public JSONArray getConfigurations(String tenantDomain)
             }
             throw new ValidationConfigurationRetrievalClientException(msg, e);
         }
-        return null;
     }
 
     /**
@@ -230,7 +221,7 @@ private String getEndpoint(String tenantDomain, String context)
         }
     }
 
-    private void setAuthorizationHeader(HttpRequestBase httpMethod) {
+    private void setAuthorizationHeader(HttpUriRequestBase httpMethod) {
 
         String toEncode = IdentityManagementServiceUtil.getInstance().getAppName() + ":"
                 + String.valueOf(IdentityManagementServiceUtil.getInstance().getAppPassword());
diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/AuthenticatorDataRetrievalClientTest.java b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/AuthenticatorDataRetrievalClientTest.java
index babf06a07cac..3a304c3e521a 100644
--- a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/AuthenticatorDataRetrievalClientTest.java
+++ b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/AuthenticatorDataRetrievalClientTest.java
@@ -24,7 +24,7 @@
 import org.testng.annotations.Test;
 import org.wso2.carbon.identity.mgt.endpoint.util.client.AuthenticatorDataRetrievalClient;
 import org.wso2.carbon.identity.mgt.endpoint.util.client.AuthenticatorDataRetrievalClientException;
-import org.wso2.carbon.utils.HTTPClientUtils;
+import org.wso2.carbon.utils.httpclient5.HTTPClientUtils;
 
 import java.io.IOException;
 import java.util.Map;
@@ -55,7 +55,7 @@ public void testGetAuthenticatorConfigs() throws AuthenticatorDataRetrievalClien
              MockedStatic<HTTPClientUtils> httpclientUtil = mockStatic(HTTPClientUtils.class)) {
             identityMgtServiceUtil.when(IdentityManagementServiceUtil::getInstance)
                     .thenReturn(identityManagementServiceUtil);
-            httpclientUtil.when(HTTPClientUtils::createClientWithCustomVerifier).thenReturn(httpClientBuilder);
+            httpclientUtil.when(HTTPClientUtils::createClientWithCustomHostnameVerifier).thenReturn(httpClientBuilder);
 
             Map<String, String> configs = authenticatorDataRetrievalClient.getAuthenticatorConfig(SUPER_TENANT_DOMAIN,
                     AUTHENTICATOR_IDENTIFIER);
diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/BrandingPreferenceRetrievalClientTest.java b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/BrandingPreferenceRetrievalClientTest.java
index 25a8ef0cab69..91bcda067fd9 100644
--- a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/BrandingPreferenceRetrievalClientTest.java
+++ b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/BrandingPreferenceRetrievalClientTest.java
@@ -25,7 +25,7 @@
 import org.testng.annotations.Test;
 import org.wso2.carbon.identity.mgt.endpoint.util.client.BrandingPreferenceRetrievalClient;
 import org.wso2.carbon.identity.mgt.endpoint.util.client.BrandingPreferenceRetrievalClientException;
-import org.wso2.carbon.utils.HTTPClientUtils;
+import org.wso2.carbon.utils.httpclient5.HTTPClientUtils;
 
 import java.io.IOException;
 
@@ -50,7 +50,7 @@ public void testGetPreference() throws BrandingPreferenceRetrievalClientExceptio
              MockedStatic<HTTPClientUtils> httpclientUtil = mockStatic(HTTPClientUtils.class)) {
             identityMgtServiceUtil.when(IdentityManagementServiceUtil::getInstance)
                     .thenReturn(identityManagementServiceUtil);
-            httpclientUtil.when(HTTPClientUtils::createClientWithCustomVerifier).thenReturn(httpClientBuilder);
+            httpclientUtil.when(HTTPClientUtils::createClientWithCustomHostnameVerifier).thenReturn(httpClientBuilder);
             JSONObject jsonObject = preferenceRetrievalClient.getPreference(SUPER_TENANT_DOMAIN, "ORG", null, "en-US");
             Assert.equals("centered",
                     ((JSONObject) ((JSONObject) jsonObject.get("preference")).get("layout")).get("activeLayout")
@@ -66,7 +66,7 @@ public void testGetCustomTextPreference() throws BrandingPreferenceRetrievalClie
              MockedStatic<HTTPClientUtils> httpclientUtil = mockStatic(HTTPClientUtils.class)) {
             identityMgtServiceUtil.when(IdentityManagementServiceUtil::getInstance)
                     .thenReturn(identityManagementServiceUtil);
-            httpclientUtil.when(HTTPClientUtils::createClientWithCustomVerifier).thenReturn(httpClientBuilder);
+            httpclientUtil.when(HTTPClientUtils::createClientWithCustomHostnameVerifier).thenReturn(httpClientBuilder);
             preferenceRetrievalClient.getCustomTextPreference(SUPER_TENANT_DOMAIN, "ORG", "", "", "en-US");
         }
     }
diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/CommonDataRetrievalClientTest.java b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/CommonDataRetrievalClientTest.java
index 09b3bbc12fe8..45dcf0f8e74a 100644
--- a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/CommonDataRetrievalClientTest.java
+++ b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/CommonDataRetrievalClientTest.java
@@ -22,7 +22,7 @@
 import org.testng.annotations.Test;
 import org.wso2.carbon.identity.mgt.endpoint.util.client.CommonDataRetrievalClient;
 import org.wso2.carbon.identity.mgt.endpoint.util.client.CommonDataRetrievalClientException;
-import org.wso2.carbon.utils.HTTPClientUtils;
+import org.wso2.carbon.utils.httpclient5.HTTPClientUtils;
 
 import static org.mockito.Mockito.mockStatic;
 
@@ -38,7 +38,7 @@ public void techCheckBooleanProperty() throws CommonDataRetrievalClientException
              MockedStatic<HTTPClientUtils> httpclientUtil = mockStatic(HTTPClientUtils.class)) {
             identityMgtServiceUtil.when(IdentityManagementServiceUtil::getInstance)
                     .thenReturn(identityManagementServiceUtil);
-            httpclientUtil.when(HTTPClientUtils::createClientWithCustomVerifier).thenReturn(httpClientBuilder);
+            httpclientUtil.when(HTTPClientUtils::createClientWithCustomHostnameVerifier).thenReturn(httpClientBuilder);
             commonDataRetrievalClient.checkBooleanProperty("", SUPER_TENANT_DOMAIN, "", false, true);
         }
     }
diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/ConfiguredAuthenticatorsRetrievalClientTest.java b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/ConfiguredAuthenticatorsRetrievalClientTest.java
index 4eadd2bb723f..917f1fb0c9de 100644
--- a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/ConfiguredAuthenticatorsRetrievalClientTest.java
+++ b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/ConfiguredAuthenticatorsRetrievalClientTest.java
@@ -23,7 +23,7 @@
 import org.testng.annotations.Test;
 import org.wso2.carbon.identity.mgt.endpoint.util.client.ConfiguredAuthenticatorsRetrievalClient;
 import org.wso2.carbon.identity.mgt.endpoint.util.client.ConfiguredAuthenticatorsRetrievalClientException;
-import org.wso2.carbon.utils.HTTPClientUtils;
+import org.wso2.carbon.utils.httpclient5.HTTPClientUtils;
 
 import static org.mockito.Mockito.mockStatic;
 
@@ -46,7 +46,7 @@ public void testGetConfiguredAuthenticators() throws ConfiguredAuthenticatorsRet
              MockedStatic<HTTPClientUtils> httpclientUtil = mockStatic(HTTPClientUtils.class)) {
             identityMgtServiceUtil.when(IdentityManagementServiceUtil::getInstance)
                     .thenReturn(identityManagementServiceUtil);
-            httpclientUtil.when(HTTPClientUtils::createClientWithCustomVerifier).thenReturn(httpClientBuilder);
+            httpclientUtil.when(HTTPClientUtils::createClientWithCustomHostnameVerifier).thenReturn(httpClientBuilder);
             configuredAuthenticatorsRetrievalClient.getConfiguredAuthenticators("", SUPER_TENANT_DOMAIN);
         }
     }
diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/IdentityManagementEndpointUtilTest.java b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/IdentityManagementEndpointUtilTest.java
index 0e2857755357..3d7ba1abd105 100644
--- a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/IdentityManagementEndpointUtilTest.java
+++ b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/IdentityManagementEndpointUtilTest.java
@@ -18,6 +18,13 @@
 
 package org.wso2.carbon.identity.mgt.endpoint.util;
 
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.core5.http.ClassicHttpRequest;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.io.HttpClientResponseHandler;
 import org.mockito.Mock;
 import org.mockito.MockedStatic;
 import org.mockito.testng.MockitoTestNGListener;
@@ -30,15 +37,21 @@
 import org.wso2.carbon.identity.core.URLBuilderException;
 import org.wso2.carbon.identity.core.util.IdentityTenantUtil;
 import org.wso2.carbon.identity.testutil.Whitebox;
+import org.wso2.carbon.utils.httpclient5.HTTPClientUtils;
 
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.util.HashMap;
 import java.util.Map;
 
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.lenient;
+import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.mockStatic;
 import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
 
 /**
  * This class tests the methods of IdentityManagementEndpointUtil class.
@@ -46,12 +59,25 @@
 @Listeners(MockitoTestNGListener.class)
 public class IdentityManagementEndpointUtilTest {
 
+    @Mock
+    HttpClientBuilder httpClientBuilder;
+
+    @Mock
+    CloseableHttpClient httpClient;
+
+    @Mock
+    HttpEntity httpEntity;
+
+    @Mock
+    ClassicHttpResponse httpResponse;
+
     @Mock
     ServiceURL serviceURL;
 
     @Mock
     private ServiceURLBuilder serviceURLBuilder;
 
+    private String mockJsonResponse = "{}";
     private static final String SAMPLE_URL = "https://wso2.org:9443";
     private static final String SAMPLE_TENANTED_URL = "https://wso2.org:9443/t/test.com";
 
@@ -350,4 +376,30 @@ private void prepareServiceURLBuilder(MockedStatic<ServiceURLBuilder> serviceURL
         lenient().when(this.serviceURLBuilder.addParameter(any(), any())).thenReturn(this.serviceURLBuilder);
         lenient().when(this.serviceURLBuilder.build()).thenReturn(serviceURL);
     }
+
+    @Test
+    public void testGetHttpClientResponseString () throws IOException {
+
+        try (MockedStatic<HTTPClientUtils> httpClientUtilsMockedStatic = mockStatic(HTTPClientUtils.class)) {
+             httpClientUtilsMockedStatic.when(HTTPClientUtils::createClientWithCustomHostnameVerifier)
+                     .thenReturn(httpClientBuilder);
+            when(httpClientBuilder.build()).thenReturn(httpClient);
+            when(httpClient.execute(any(ClassicHttpRequest.class), any(HttpClientResponseHandler.class)))
+                    .thenAnswer(invocation -> {
+                        HttpClientResponseHandler<?> handler = invocation.getArgument(1);
+                        return handler.handleResponse(httpResponse);
+                    });
+
+            when(httpResponse.getCode()).thenReturn(200);
+            when(httpResponse.getEntity()).thenReturn(httpEntity);
+            InputStream inputStream = new ByteArrayInputStream(mockJsonResponse.getBytes());
+            when(httpEntity.getContent()).thenReturn(inputStream);
+
+            HttpGet httpGet = new HttpGet("https://localhost:9443");
+
+            String responseString = IdentityManagementEndpointUtil.getHttpClientResponseString(httpGet);
+            assertNotNull(responseString);
+        }
+    }
+
 }
diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/IdentityProviderDataRetrievalClientTest.java b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/IdentityProviderDataRetrievalClientTest.java
index 1092a57d3336..d54a724a88ab 100644
--- a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/IdentityProviderDataRetrievalClientTest.java
+++ b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/IdentityProviderDataRetrievalClientTest.java
@@ -18,22 +18,19 @@
 
 package org.wso2.carbon.identity.mgt.endpoint.util;
 
-import org.apache.http.client.methods.HttpGet;
 import org.locationtech.jts.util.Assert;
 import org.mockito.MockedStatic;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 import org.wso2.carbon.identity.mgt.endpoint.util.client.IdentityProviderDataRetrievalClient;
 import org.wso2.carbon.identity.mgt.endpoint.util.client.IdentityProviderDataRetrievalClientException;
-import org.wso2.carbon.utils.HTTPClientUtils;
+import org.wso2.carbon.utils.httpclient5.HTTPClientUtils;
 
 import java.io.IOException;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mockStatic;
-import static org.mockito.Mockito.when;
 
 public class IdentityProviderDataRetrievalClientTest extends RetrievalClientBaseTest {
 
@@ -56,7 +53,7 @@ public void testGetIdPImage() throws IdentityProviderDataRetrievalClientExceptio
              MockedStatic<HTTPClientUtils> httpclientUtil = mockStatic(HTTPClientUtils.class)) {
             identityMgtServiceUtil.when(IdentityManagementServiceUtil::getInstance)
                     .thenReturn(identityManagementServiceUtil);
-            httpclientUtil.when(HTTPClientUtils::createClientWithCustomVerifier).thenReturn(httpClientBuilder);
+            httpclientUtil.when(HTTPClientUtils::createClientWithCustomHostnameVerifier).thenReturn(httpClientBuilder);
             String imageKey = identityProviderDataRetrievalClient.getIdPImage(SUPER_TENANT_DOMAIN, idpName);
             Assert.equals("assets/images/logos/enterprise.svg", imageKey);
         }
@@ -70,8 +67,7 @@ public void testGetFederatedIdpConfigs() throws IdentityProviderDataRetrievalCli
              MockedStatic<HTTPClientUtils> httpclientUtil = mockStatic(HTTPClientUtils.class)) {
             identityMgtServiceUtil.when(IdentityManagementServiceUtil::getInstance)
                     .thenReturn(identityManagementServiceUtil);
-            httpclientUtil.when(HTTPClientUtils::createClientWithCustomVerifier).thenReturn(httpClientBuilder);
-            when(httpClient.execute(any(HttpGet.class))).thenReturn(httpResponse);
+            httpclientUtil.when(HTTPClientUtils::createClientWithCustomHostnameVerifier).thenReturn(httpClientBuilder);
 
             identityProviderDataRetrievalClient.getFederatedIdpConfigs(SUPER_TENANT_DOMAIN, "idp-code", idpName,
                     Stream.of("key").collect(Collectors.toList()));
diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/OrganizationDiscoveryConfigDataRetrievalClientTest.java b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/OrganizationDiscoveryConfigDataRetrievalClientTest.java
index 0191118f23ca..6894ebbc4ea5 100644
--- a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/OrganizationDiscoveryConfigDataRetrievalClientTest.java
+++ b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/OrganizationDiscoveryConfigDataRetrievalClientTest.java
@@ -23,7 +23,7 @@
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 import org.wso2.carbon.identity.mgt.endpoint.util.client.OrganizationDiscoveryConfigDataRetrievalClient;
-import org.wso2.carbon.utils.HTTPClientUtils;
+import org.wso2.carbon.utils.httpclient5.HTTPClientUtils;
 
 import java.io.IOException;
 import java.util.Map;
@@ -52,7 +52,7 @@ public void testGetDiscoveryConfiguration() throws Exception {
              MockedStatic<HTTPClientUtils> httpclientUtil = mockStatic(HTTPClientUtils.class)) {
             identityMgtServiceUtil.when(IdentityManagementServiceUtil::getInstance)
                     .thenReturn(identityManagementServiceUtil);
-            httpclientUtil.when(HTTPClientUtils::createClientWithCustomVerifier).thenReturn(httpClientBuilder);
+            httpclientUtil.when(HTTPClientUtils::createClientWithCustomHostnameVerifier).thenReturn(httpClientBuilder);
             Map<String, String> result =
                     orgDiscoveryConfigDataRetrievalClient.getDiscoveryConfiguration(SUPER_TENANT_DOMAIN);
             Assert.assertEquals(result.size(), 2);
diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/PreferenceRetrievalClientTest.java b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/PreferenceRetrievalClientTest.java
index 796c4da53db2..6a8660c11c16 100644
--- a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/PreferenceRetrievalClientTest.java
+++ b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/PreferenceRetrievalClientTest.java
@@ -18,10 +18,17 @@
 
 package org.wso2.carbon.identity.mgt.endpoint.util;
 
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.mockito.Mock;
+import org.mockito.MockedStatic;
+import org.mockito.MockedConstruction;
 import org.mockito.MockitoAnnotations;
 import org.mockito.Spy;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
+import org.wso2.carbon.identity.core.ServiceURL;
+import org.wso2.carbon.identity.core.ServiceURLBuilder;
+import org.wso2.carbon.identity.core.URLBuilderException;
 import org.wso2.carbon.identity.mgt.endpoint.util.client.PreferenceRetrievalClient;
 import org.wso2.carbon.identity.mgt.endpoint.util.client.PreferenceRetrievalClientException;
 
@@ -31,9 +38,7 @@
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.*;
 import static org.testng.Assert.assertTrue;
 
 public class PreferenceRetrievalClientTest {
@@ -71,9 +76,17 @@ public class PreferenceRetrievalClientTest {
     private static final String ACCOUNT_MGT_GOVERNANCE = "Account Management";
     private static final String USER_ONBOARDING_GOVERNANCE = "User Onboarding";
 
+    private static final String SERVICE_URL = "https://localhost:9443";
+
     @Spy
     private PreferenceRetrievalClient preferenceRetrievalClient;
 
+    @Mock
+    ServiceURL serviceURL;
+
+    @Mock
+    private ServiceURLBuilder serviceURLBuilder;
+
     @BeforeMethod
     public void setUp() {
 
@@ -333,4 +346,44 @@ public void testCheckIfLiteRegCallbackURLValid() throws PreferenceRetrievalClien
         verify(preferenceRetrievalClient, times(1)).getPropertyValue(tenantDomain, USER_ONBOARDING_GOVERNANCE,
                 LITE_USER_CONNECTOR, LITE_REG_CALLBACK_REGEX_PROP);
     }
+
+    @Test
+    public void testGetPropertyValue() throws PreferenceRetrievalClientException, URLBuilderException {
+
+        try (MockedStatic<ServiceURLBuilder> serviceURLBuilder = mockStatic(ServiceURLBuilder.class);
+             MockedStatic<IdentityManagementEndpointUtil> identityManagementEndpointUtilMockedStatic =
+                     mockStatic(IdentityManagementEndpointUtil.class);
+             MockedConstruction<HttpGet> httpGetConstruction = mockConstruction(HttpGet.class)) {
+
+            prepareServiceURLBuilder(serviceURLBuilder);
+            prepareServiceURL();
+
+            String firstResponse = "[]";
+            String secondResponse = "{\"connectors\":[]}";
+            identityManagementEndpointUtilMockedStatic.when(() ->
+                    IdentityManagementEndpointUtil.getHttpClientResponseString(any()))
+                .thenReturn(firstResponse, secondResponse);
+
+            preferenceRetrievalClient.getPropertyValue(tenantDomain, USER_ONBOARDING_GOVERNANCE, LITE_USER_CONNECTOR,
+                    LITE_REG_CALLBACK_REGEX_PROP);
+        }
+
+    }
+
+    /**
+     * Prepare service URL.
+     */
+    private void prepareServiceURL() {
+
+        when(serviceURL.getAbsoluteInternalURL()).thenReturn(SERVICE_URL);
+    }
+
+    /**
+     * Prepare service URL builder.
+     */
+    private void prepareServiceURLBuilder(MockedStatic<ServiceURLBuilder> serviceURLBuilder) throws URLBuilderException {
+
+        serviceURLBuilder.when(ServiceURLBuilder::create).thenReturn(this.serviceURLBuilder);
+        when(this.serviceURLBuilder.build()).thenReturn(serviceURL);
+    }
 }
diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/RetrievalClientBaseTest.java b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/RetrievalClientBaseTest.java
index 6ba004bbcf97..a9e1b1f91168 100644
--- a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/RetrievalClientBaseTest.java
+++ b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/RetrievalClientBaseTest.java
@@ -18,11 +18,12 @@
 
 package org.wso2.carbon.identity.mgt.endpoint.util;
 
-import org.apache.http.HttpEntity;
-import org.apache.http.StatusLine;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.hc.core5.http.ClassicHttpRequest;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.core5.http.io.HttpClientResponseHandler;
 import org.mockito.Mock;
 import org.mockito.testng.MockitoTestNGListener;
 import org.testng.annotations.BeforeMethod;
@@ -51,11 +52,9 @@ public class RetrievalClientBaseTest {
     @Mock
     CloseableHttpClient httpClient;
     @Mock
-    StatusLine statusLine;
-    @Mock
     HttpEntity httpEntity;
     @Mock
-    CloseableHttpResponse httpResponse;
+    ClassicHttpResponse httpResponse;
 
     private String mockJsonResponse = "{}";
     public static final String SUPER_TENANT_DOMAIN = "carbon.super";
@@ -75,12 +74,15 @@ public void setMockJsonResponse(String mockJsonResponse) {
 
     @BeforeMethod
     public void setup() throws IOException {
-
         setupConfiguration();
         when(httpClientBuilder.build()).thenReturn(httpClient);
-        when(httpClient.execute(any())).thenReturn(httpResponse);
-        when(httpResponse.getStatusLine()).thenReturn(statusLine);
-        when(statusLine.getStatusCode()).thenReturn(200);
+        when(httpClient.execute(any(ClassicHttpRequest.class), any(HttpClientResponseHandler.class)))
+                .thenAnswer(invocation -> {
+                    HttpClientResponseHandler<?> handler = invocation.getArgument(1);
+                    return handler.handleResponse(httpResponse);
+                });
+
+        when(httpResponse.getCode()).thenReturn(200);
         when(httpResponse.getEntity()).thenReturn(httpEntity);
         InputStream inputStream = new ByteArrayInputStream(mockJsonResponse.getBytes());
         when(httpEntity.getContent()).thenReturn(inputStream);
diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/ValidationConfigurationRetrievalClientTest.java b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/ValidationConfigurationRetrievalClientTest.java
index 55a7d0d4d5cb..1a2adc588f0a 100644
--- a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/ValidationConfigurationRetrievalClientTest.java
+++ b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/test/java/org/wso2/carbon/identity/mgt/endpoint/util/ValidationConfigurationRetrievalClientTest.java
@@ -26,7 +26,7 @@
 import org.testng.annotations.Test;
 import org.wso2.carbon.identity.mgt.endpoint.util.client.ValidationConfigurationRetrievalClient;
 import org.wso2.carbon.identity.mgt.endpoint.util.client.ValidationConfigurationRetrievalClientException;
-import org.wso2.carbon.utils.HTTPClientUtils;
+import org.wso2.carbon.utils.httpclient5.HTTPClientUtils;
 
 import java.io.IOException;
 
@@ -51,7 +51,7 @@ public void testGetConfigurations() throws ValidationConfigurationRetrievalClien
              MockedStatic<HTTPClientUtils> httpclientUtil = mockStatic(HTTPClientUtils.class)) {
             identityMgtServiceUtil.when(IdentityManagementServiceUtil::getInstance)
                     .thenReturn(identityManagementServiceUtil);
-            httpclientUtil.when(HTTPClientUtils::createClientWithCustomVerifier).thenReturn(httpClientBuilder);
+            httpclientUtil.when(HTTPClientUtils::createClientWithCustomHostnameVerifier).thenReturn(httpClientBuilder);
             JSONArray jsonArray = validationConfigurationRetrievalClient.getConfigurations(SUPER_TENANT_DOMAIN);
             JSONObject jsonObject = (JSONObject) jsonArray.get(0);
             jsonArray = (JSONArray) jsonObject.get("rules");
diff --git a/pom.xml b/pom.xml
index f88af6e4cc0c..fe7c36c070ba 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1828,6 +1828,16 @@
                 <artifactId>httpclient</artifactId>
                 <version>${apache.httpcomponents.httpclient.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.wso2.orbit.org.apache.httpcomponents</groupId>
+                <artifactId>httpcore5</artifactId>
+                <version>${orbit.version.httpcore5}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.wso2.orbit.org.apache.httpcomponents</groupId>
+                <artifactId>httpclient5</artifactId>
+                <version>${orbit.version.httpclient5}</version>
+            </dependency>
             <dependency>
                 <groupId>org.wso2.carbon.identity.framework</groupId>
                 <artifactId>org.wso2.carbon.identity.central.log.mgt</artifactId>
@@ -1958,11 +1968,13 @@
         <codehaus.jettison.version>1.4.0</codehaus.jettison.version>
         <jaxrx.jsr311.api.version>1.1.1</jaxrx.jsr311.api.version>
         <apache.httpcomponents.httpclient.version>4.3.5</apache.httpcomponents.httpclient.version>
+        <orbit.version.httpcore5>5.3.1.wso2v1</orbit.version.httpcore5>
+        <orbit.version.httpclient5>5.4.1.wso2v1</orbit.version.httpclient5>
 
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 
         <!-- Carbon kernel version -->
-        <carbon.kernel.version>4.10.51</carbon.kernel.version>
+        <carbon.kernel.version>4.10.53</carbon.kernel.version>
         <carbon.kernel.feature.version>4.7.0</carbon.kernel.feature.version>
         <carbon.kernel.package.import.version.range>[4.5.0, 5.0.0)</carbon.kernel.package.import.version.range>
         <carbon.kernel.registry.imp.pkg.version>[1.0.1, 2.0.0)</carbon.kernel.registry.imp.pkg.version>


Reviews:
user: login: copilot-pull-request-reviewer[bot]
body: ## Pull Request Overview

This pull request migrates the HTTP client implementation from Apache HTTP Client 4 to Apache HTTP Client 5 across various identity management and authentication client classes and their tests. Key changes include updating import statements and API calls to use the new HTTPClientUtils from httpclient5, as well as adjusting response handling logic using lambda-based execution methods.

### Reviewed Changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.

| File | Description |
| ---- | ----------- |
| IdentityProviderDataRetrievalClientTest.java | Updated test class to use HTTPClientUtils from httpclient5. |
| Multiple client classes (e.g. ValidationConfigurationRetrievalClient, SelfRegistrationMgtClient, etc.) | Updated client classes to use Apache HTTP Client 5 API for executing requests and processing responses. |
| pom.xml files | Removed dependencies for HTTP Client 4 and added dependencies for HTTPClient5 and httpcore5. |
| AuthAPIServiceClient.java | Updated authentication client to utilize new HTTPClient API and create clients using system properties. |


<details>
<summary>Comments suppressed due to low confidence (1)</summary>

**components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/ValidationConfigurationRetrievalClient.java:87**
* [nitpick] The lambda-based response extraction logic is duplicated across multiple client classes; consider extracting this common code into a shared utility method to reduce repetition and improve maintainability.
```
String responseString = httpclient.execute(request, response -> { ... }
```
</details>


state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-08T12:57:16Z
user: login: madurangasiriwardena
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-08T13:58:17Z
user: login: linukaratnayake
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-14T05:07:54Z
user: login: linukaratnayake
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-20T10:03:46Z
user: login: copilot-pull-request-reviewer[bot]
body: ## Pull Request Overview

This pull request migrates the codebase from Apache HTTP Client 4 to Apache HTTP Client 5. Key changes include updating import statements and modifying HTTP client creation and response handling patterns to use the new HttpClient 5 APIs.

### Reviewed Changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 2 comments.

| File | Description |
| ---- | ----------- |
| *Test files (e.g., ConfiguredAuthenticatorsRetrievalClientTest.java, CommonDataRetrievalClientTest.java, etc.) | Updated HTTP client utility import and method calls (e.g. createClientWithCustomHostnameVerifier) to align with HttpClient 5 usage. |
| ValidationConfigurationRetrievalClient.java, SelfRegistrationMgtClient.java, PreferenceRetrievalClient.java | Modified request/response handling to use the new getHttpClientResponseString helper and updated authorization header methods to use HttpUriRequestBase. |
| Multiple client classes (AuthenticatorDataRetrievalClient.java, IdentityProviderDataRetrievalClient.java, etc.) | Adapted client logic and dependency management (pom.xml) for HttpClient 5, replacing deprecated CloseableHttpResponse usages and client builder invocations. |
| AuthAPIServiceClient.java and AuthenticationEndpointUtil.java | Updated HTTP method calls leveraging HttpClient 5’s APIs and helper methods for obtaining response strings, ensuring consistency across service client implementations. |




state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-21T13:35:53Z
user: login: hwupathum
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-21T14:00:18Z
user: login: jenkins-is-staging
body: Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/15164987580
state: APPROVED
author_association: NONE
submitted_at: 2025-05-21T19:58:35Z
user: login: hwupathum
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-05-22T10:30:57Z

Review comments:
diff_hunk: @@ -157,31 +157,31 @@ private String executeGet(String url) throws SelfRegistrationMgtClientException,
 
         boolean isDebugEnabled = log.isDebugEnabled();
         try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomVerifier().build()) {
-
             HttpGet httpGet = new HttpGet(url);
             setAuthorizationHeader(httpGet);
 
-            try (CloseableHttpResponse response = httpclient.execute(httpGet)) {
+            try {
+                return httpclient.execute(httpGet, response -> {
+                    if (isDebugEnabled) {
+                        log.debug("HTTP status " + response.getCode() + " when invoking GET for URL: "
+                                + url);
+                    }
 
-                if (isDebugEnabled) {
-                    log.debug("HTTP status " + response.getStatusLine().getStatusCode() + " when invoking GET for URL: "
-                            + url);
-                }
-                if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-                    BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
-                    String inputLine;
-                    StringBuilder responseString = new StringBuilder();
+                    if (response.getCode() == HttpStatus.SC_OK) {
+                        BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
+                        String inputLine;
+                        StringBuilder responseString = new StringBuilder();
 
-                    while ((inputLine = reader.readLine()) != null) {
-                        responseString.append(inputLine);
+                        while ((inputLine = reader.readLine()) != null) {
+                            responseString.append(inputLine);
+                        }
+                        return responseString.toString();
                     }
-                    return responseString.toString();
-                } else {
-                    throw new SelfRegistrationMgtClientException("Error while retrieving data from " + url + ". " +
-                            "Found http status " + response.getStatusLine());
-                }
-            } finally {
-                httpGet.releaseConnection();
+                    throw new RuntimeException(String.valueOf(response.getCode()));
path: components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/SelfRegistrationMgtClient.java
user: login: Copilot
body: Instead of throwing a generic RuntimeException with the status code, consider throwing a SelfRegistrationMgtClientException directly with a descriptive error message to improve error clarity and consistency.
```suggestion
                    throw new SelfRegistrationMgtClientException("Failed to retrieve data from " + url +
                            ". HTTP status code: " + response.getCode());
```
created_at: 2025-05-08T12:57:16Z
author_association: CONTRIBUTOR
diff_hunk: @@ -405,26 +403,27 @@ public static String sendGetRequest(String backendURL) {
      * @return Extracted http response content.
      * @throws IOException if there is an error while extracting the response content.
      */
-    private static StringBuilder handleHttpResponse(CloseableHttpResponse response, String backendURL) throws IOException {
+    private static StringBuilder handleHttpResponse(ClassicHttpResponse response, String backendURL)
path: components/authentication-framework/org.wso2.carbon.identity.application.authentication.endpoint.util/src/main/java/org/wso2/carbon/identity/application/authentication/endpoint/util/AuthenticationEndpointUtil.java
user: login: madurangasiriwardena
body: Shall we change the return type to string, which will simplify the caller of this method.
created_at: 2025-05-08T13:46:57Z
author_association: MEMBER
diff_hunk: @@ -80,37 +78,43 @@ public AuthenticationResponse authenticate(String username, Object password) thr
 
         String endpointURL = basePath + "authenticate";
 
-        AuthenticationResponse authenticationResponse;
         HttpPost httpPostRequest = new HttpPost(endpointURL);
         httpPostRequest.setHeader(HttpHeaders.AUTHORIZATION, buildBasicAuthHeader(username, password));
         httpPostRequest.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
-        try (CloseableHttpResponse response = httpClient.execute(httpPostRequest)) {
 
-            int statusCode = response.getStatusLine().getStatusCode();
-            String responseString = extractResponse(response);
-            if (log.isDebugEnabled()) {
-                log.debug("Response: { status: " + response.getStatusLine().getStatusCode() + "\n data: " +
+        try (CloseableHttpClient httpClient = HTTPClientUtils.createClientWithSystemProperties().build()) {
+            return httpClient.execute(httpPostRequest, response -> {
+
+                String responseString;
+                try {
+                    responseString = extractResponse(response);
+                } catch (ServiceClientException e) {
+                    throw new RuntimeException(e);
+                }
+                if (log.isDebugEnabled()) {
+                log.debug("Response: { status: " + response.getCode() + "\n data: " +
path: components/authentication-framework/org.wso2.carbon.identity.application.authentication.endpoint.util/src/main/java/org/wso2/carbon/identity/application/authentication/endpoint/util/client/AuthAPIServiceClient.java
user: login: madurangasiriwardena
body: Formatting is not correct
created_at: 2025-05-08T13:51:36Z
author_association: MEMBER
diff_hunk: @@ -157,31 +157,31 @@ private String executeGet(String url) throws SelfRegistrationMgtClientException,
 
         boolean isDebugEnabled = log.isDebugEnabled();
         try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomVerifier().build()) {
-
             HttpGet httpGet = new HttpGet(url);
             setAuthorizationHeader(httpGet);
 
-            try (CloseableHttpResponse response = httpclient.execute(httpGet)) {
+            try {
+                return httpclient.execute(httpGet, response -> {
+                    if (isDebugEnabled) {
+                        log.debug("HTTP status " + response.getCode() + " when invoking GET for URL: "
+                                + url);
+                    }
 
-                if (isDebugEnabled) {
-                    log.debug("HTTP status " + response.getStatusLine().getStatusCode() + " when invoking GET for URL: "
-                            + url);
-                }
-                if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-                    BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
-                    String inputLine;
-                    StringBuilder responseString = new StringBuilder();
+                    if (response.getCode() == HttpStatus.SC_OK) {
+                        BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
+                        String inputLine;
+                        StringBuilder responseString = new StringBuilder();
 
-                    while ((inputLine = reader.readLine()) != null) {
-                        responseString.append(inputLine);
+                        while ((inputLine = reader.readLine()) != null) {
+                            responseString.append(inputLine);
+                        }
+                        return responseString.toString();
                     }
-                    return responseString.toString();
-                } else {
-                    throw new SelfRegistrationMgtClientException("Error while retrieving data from " + url + ". " +
-                            "Found http status " + response.getStatusLine());
-                }
-            } finally {
-                httpGet.releaseConnection();
+                    throw new RuntimeException(String.valueOf(response.getCode()));
path: components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/SelfRegistrationMgtClient.java
user: login: linukaratnayake
body: Since this is a lambda expression, only `RuntimeException` is possible.
created_at: 2025-05-14T05:07:54Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1882,11 +1897,13 @@
         <codehaus.jettison.version>1.4.0</codehaus.jettison.version>
         <jaxrx.jsr311.api.version>1.1.1</jaxrx.jsr311.api.version>
         <apache.httpcomponents.httpclient.version>4.3.5</apache.httpcomponents.httpclient.version>
+        <orbit.version.httpcore5>5.3.1.wso2v1</orbit.version.httpcore5>
+        <orbit.version.httpclient5>5.4.1.wso2v1</orbit.version.httpclient5>
 
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 
         <!-- Carbon kernel version -->
-        <carbon.kernel.version>4.10.34</carbon.kernel.version>
+        <carbon.kernel.version>4.10.43-SNAPSHOT</carbon.kernel.version>
path: pom.xml
user: login: linukaratnayake
body: ```suggestion
        <carbon.kernel.version>4.10.34</carbon.kernel.version>
```
created_at: 2025-05-20T10:03:45Z
author_association: CONTRIBUTOR
diff_hunk: @@ -334,15 +330,14 @@ private JSONObject checkUserNameValidityInternal(User user, boolean skipSignUpCh
                     }
                     // Logging and throwing since this is a client
                     if (log.isDebugEnabled()) {
-                        log.debug("Unexpected response code found: " + response.getStatusLine().getStatusCode()
+                        log.debug("Unexpected response code found: " + statusCode
                                 + " when validating username: " + user.getUsername());
                     }
-                    throw new SelfRegistrationMgtClientException("Error while checking username validity for user : "
-                            + user.getUsername());
+                    throw new RuntimeException();
path: components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/SelfRegistrationMgtClient.java
user: login: Copilot
body: Avoid throwing a bare RuntimeException here; consider throwing a more specific SelfRegistrationMgtClientException (or preserving and propagating the caught exception details) to retain useful debugging information.
```suggestion
                    throw new SelfRegistrationMgtClientException("Unexpected response code: " + statusCode
                            + " when validating username: " + user.getUsername());
```
created_at: 2025-05-21T13:35:53Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1026,4 +1032,31 @@ private static void updateCookieConfig(CookieBuilder cookieBuilder, IdentityCook
 
         cookieBuilder.setSecure(cookieConfig.isSecure());
     }
+
+    /**
+     * Executes the HTTP client request and returns the response as a string.
+     *
+     * @return String
+     */
+     public static String getHttpClientResponseString(HttpUriRequestBase request) throws IOException {
path: components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/IdentityManagementEndpointUtil.java
user: login: Copilot
body: Since this helper returns null when the response status is not SC_OK, ensure that all callers of this method appropriately handle null responses to avoid unexpected behavior.
```suggestion
     * @param request The HTTP request to execute.
     * @return The response body as a string.
     * @throws IOException If an I/O error occurs or the response status is not SC_OK.
     */
    public static String getHttpClientResponseString(HttpUriRequestBase request) throws IOException {
```
created_at: 2025-05-21T13:35:53Z
author_association: CONTRIBUTOR
diff_hunk: @@ -258,6 +251,22 @@ public String getApplicationID(String tenant, String applicationName)
         }
     }
 
+    /**
+     * Parses a JSON response string and extracts a single application object if available.
+     *
+     * @param responseString JSON response string from API
+     * @return the single application JSONObject or null if not exactly one application is found
+     * @throws JSONException if parsing the JSON response fails
+     */
+    private JSONObject getSingleApplicationFromResponse(String responseString) throws JSONException {
path: components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/ApplicationDataRetrievalClient.java
user: login: hwupathum
body: Add newline
created_at: 2025-05-21T14:00:17Z
author_association: CONTRIBUTOR

PR comments:
user: login: codecov[bot]
created_at: 2025-05-21T07:49:10Z
body: ## [Codecov](https://app.codecov.io/gh/wso2/carbon-identity-framework/pull/6721?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2) Report
Attention: Patch coverage is `24.20091%` with `166 lines` in your changes missing coverage. Please review.
> Project coverage is 47.60%. Comparing base [(`54670c9`)](https://app.codecov.io/gh/wso2/carbon-identity-framework/commit/54670c93819010c8b7b29a44b93b0bc6ef91edc4?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2) to head [(`5f16ef2`)](https://app.codecov.io/gh/wso2/carbon-identity-framework/commit/5f16ef28e0242c3aea2371c67b0796cf85e852b3?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2).
> Report is 52 commits behind head on master.

| [Files with missing lines](https://app.codecov.io/gh/wso2/carbon-identity-framework/pull/6721?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2) | Patch % | Lines |
|---|---|---|
| [...nt/util/client/ApplicationDataRetrievalClient.java](https://app.codecov.io/gh/wso2/carbon-identity-framework/pull/6721?src=pr&el=tree&filepath=components%2Fidentity-mgt%2Forg.wso2.carbon.identity.mgt.endpoint.util%2Fsrc%2Fmain%2Fjava%2Forg%2Fwso2%2Fcarbon%2Fidentity%2Fmgt%2Fendpoint%2Futil%2Fclient%2FApplicationDataRetrievalClient.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2#diff-Y29tcG9uZW50cy9pZGVudGl0eS1tZ3Qvb3JnLndzbzIuY2FyYm9uLmlkZW50aXR5Lm1ndC5lbmRwb2ludC51dGlsL3NyYy9tYWluL2phdmEvb3JnL3dzbzIvY2FyYm9uL2lkZW50aXR5L21ndC9lbmRwb2ludC91dGlsL2NsaWVudC9BcHBsaWNhdGlvbkRhdGFSZXRyaWV2YWxDbGllbnQuamF2YQ==) | 0.00% | [42 Missing :warning: ](https://app.codecov.io/gh/wso2/carbon-identity-framework/pull/6721?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2) |
| [...ndpoint/util/client/PreferenceRetrievalClient.java](https://app.codecov.io/gh/wso2/carbon-identity-framework/pull/6721?src=pr&el=tree&filepath=components%2Fidentity-mgt%2Forg.wso2.carbon.identity.mgt.endpoint.util%2Fsrc%2Fmain%2Fjava%2Forg%2Fwso2%2Fcarbon%2Fidentity%2Fmgt%2Fendpoint%2Futil%2Fclient%2FPreferenceRetrievalClient.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2#diff-Y29tcG9uZW50cy9pZGVudGl0eS1tZ3Qvb3JnLndzbzIuY2FyYm9uLmlkZW50aXR5Lm1ndC5lbmRwb2ludC51dGlsL3NyYy9tYWluL2phdmEvb3JnL3dzbzIvY2FyYm9uL2lkZW50aXR5L21ndC9lbmRwb2ludC91dGlsL2NsaWVudC9QcmVmZXJlbmNlUmV0cmlldmFsQ2xpZW50LmphdmE=) | 20.00% | [36 Missing and 4 partials :warning: ](https://app.codecov.io/gh/wso2/carbon-identity-framework/pull/6721?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2) |
| [...ndpoint/util/client/SelfRegistrationMgtClient.java](https://app.codecov.io/gh/wso2/carbon-identity-framework/pull/6721?src=pr&el=tree&filepath=components%2Fidentity-mgt%2Forg.wso2.carbon.identity.mgt.endpoint.util%2Fsrc%2Fmain%2Fjava%2Forg%2Fwso2%2Fcarbon%2Fidentity%2Fmgt%2Fendpoint%2Futil%2Fclient%2FSelfRegistrationMgtClient.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2#diff-Y29tcG9uZW50cy9pZGVudGl0eS1tZ3Qvb3JnLndzbzIuY2FyYm9uLmlkZW50aXR5Lm1ndC5lbmRwb2ludC51dGlsL3NyYy9tYWluL2phdmEvb3JnL3dzbzIvY2FyYm9uL2lkZW50aXR5L21ndC9lbmRwb2ludC91dGlsL2NsaWVudC9TZWxmUmVnaXN0cmF0aW9uTWd0Q2xpZW50LmphdmE=) | 0.00% | [35 Missing :warning: ](https://app.codecov.io/gh/wso2/carbon-identity-framework/pull/6721?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2) |
| [...tion/endpoint/util/AuthenticationEndpointUtil.java](https://app.codecov.io/gh/wso2/carbon-identity-framework/pull/6721?src=pr&el=tree&filepath=components%2Fauthentication-framework%2Forg.wso2.carbon.identity.application.authentication.endpoint.util%2Fsrc%2Fmain%2Fjava%2Forg%2Fwso2%2Fcarbon%2Fidentity%2Fapplication%2Fauthentication%2Fendpoint%2Futil%2FAuthenticationEndpointUtil.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2#diff-Y29tcG9uZW50cy9hdXRoZW50aWNhdGlvbi1mcmFtZXdvcmsvb3JnLndzbzIuY2FyYm9uLmlkZW50aXR5LmFwcGxpY2F0aW9uLmF1dGhlbnRpY2F0aW9uLmVuZHBvaW50LnV0aWwvc3JjL21haW4vamF2YS9vcmcvd3NvMi9jYXJib24vaWRlbnRpdHkvYXBwbGljYXRpb24vYXV0aGVudGljYXRpb24vZW5kcG9pbnQvdXRpbC9BdXRoZW50aWNhdGlvbkVuZHBvaW50VXRpbC5qYXZh) | 0.00% | [11 Missing :warning: ](https://app.codecov.io/gh/wso2/carbon-identity-framework/pull/6721?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2) |
| [...ion/endpoint/util/client/AuthAPIServiceClient.java](https://app.codecov.io/gh/wso2/carbon-identity-framework/pull/6721?src=pr&el=tree&filepath=components%2Fauthentication-framework%2Forg.wso2.carbon.identity.application.authentication.endpoint.util%2Fsrc%2Fmain%2Fjava%2Forg%2Fwso2%2Fcarbon%2Fidentity%2Fapplication%2Fauthentication%2Fendpoint%2Futil%2Fclient%2FAuthAPIServiceClient.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2#diff-Y29tcG9uZW50cy9hdXRoZW50aWNhdGlvbi1mcmFtZXdvcmsvb3JnLndzbzIuY2FyYm9uLmlkZW50aXR5LmFwcGxpY2F0aW9uLmF1dGhlbnRpY2F0aW9uLmVuZHBvaW50LnV0aWwvc3JjL21haW4vamF2YS9vcmcvd3NvMi9jYXJib24vaWRlbnRpdHkvYXBwbGljYXRpb24vYXV0aGVudGljYXRpb24vZW5kcG9pbnQvdXRpbC9jbGllbnQvQXV0aEFQSVNlcnZpY2VDbGllbnQuamF2YQ==) | 0.00% | [11 Missing :warning: ](https://app.codecov.io/gh/wso2/carbon-identity-framework/pull/6721?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2) |
| [.../util/client/AdminAdvisoryDataRetrievalClient.java](https://app.codecov.io/gh/wso2/carbon-identity-framework/pull/6721?src=pr&el=tree&filepath=components%2Fidentity-mgt%2Forg.wso2.carbon.identity.mgt.endpoint.util%2Fsrc%2Fmain%2Fjava%2Forg%2Fwso2%2Fcarbon%2Fidentity%2Fmgt%2Fendpoint%2Futil%2Fclient%2FAdminAdvisoryDataRetrievalClient.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2#diff-Y29tcG9uZW50cy9pZGVudGl0eS1tZ3Qvb3JnLndzbzIuY2FyYm9uLmlkZW50aXR5Lm1ndC5lbmRwb2ludC51dGlsL3NyYy9tYWluL2phdmEvb3JnL3dzbzIvY2FyYm9uL2lkZW50aXR5L21ndC9lbmRwb2ludC91dGlsL2NsaWVudC9BZG1pbkFkdmlzb3J5RGF0YVJldHJpZXZhbENsaWVudC5qYXZh) | 0.00% | [7 Missing :warning: ](https://app.codecov.io/gh/wso2/carbon-identity-framework/pull/6721?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2) |
| [...il/client/IdentityProviderDataRetrievalClient.java](https://app.codecov.io/gh/wso2/carbon-identity-framework/pull/6721?src=pr&el=tree&filepath=components%2Fidentity-mgt%2Forg.wso2.carbon.identity.mgt.endpoint.util%2Fsrc%2Fmain%2Fjava%2Forg%2Fwso2%2Fcarbon%2Fidentity%2Fmgt%2Fendpoint%2Futil%2Fclient%2FIdentityProviderDataRetrievalClient.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2#diff-Y29tcG9uZW50cy9pZGVudGl0eS1tZ3Qvb3JnLndzbzIuY2FyYm9uLmlkZW50aXR5Lm1ndC5lbmRwb2ludC51dGlsL3NyYy9tYWluL2phdmEvb3JnL3dzbzIvY2FyYm9uL2lkZW50aXR5L21ndC9lbmRwb2ludC91dGlsL2NsaWVudC9JZGVudGl0eVByb3ZpZGVyRGF0YVJldHJpZXZhbENsaWVudC5qYXZh) | 53.84% | [3 Missing and 3 partials :warning: ](https://app.codecov.io/gh/wso2/carbon-identity-framework/pull/6721?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2) |
| [...ndpoint/util/client/CommonDataRetrievalClient.java](https://app.codecov.io/gh/wso2/carbon-identity-framework/pull/6721?src=pr&el=tree&filepath=components%2Fidentity-mgt%2Forg.wso2.carbon.identity.mgt.endpoint.util%2Fsrc%2Fmain%2Fjava%2Forg%2Fwso2%2Fcarbon%2Fidentity%2Fmgt%2Fendpoint%2Futil%2Fclient%2FCommonDataRetrievalClient.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2#diff-Y29tcG9uZW50cy9pZGVudGl0eS1tZ3Qvb3JnLndzbzIuY2FyYm9uLmlkZW50aXR5Lm1ndC5lbmRwb2ludC51dGlsL3NyYy9tYWluL2phdmEvb3JnL3dzbzIvY2FyYm9uL2lkZW50aXR5L21ndC9lbmRwb2ludC91dGlsL2NsaWVudC9Db21tb25EYXRhUmV0cmlldmFsQ2xpZW50LmphdmE=) | 50.00% | [1 Missing and 2 partials :warning: ](https://app.codecov.io/gh/wso2/carbon-identity-framework/pull/6721?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2) |
| [.../endpoint/util/IdentityManagementEndpointUtil.java](https://app.codecov.io/gh/wso2/carbon-identity-framework/pull/6721?src=pr&el=tree&filepath=components%2Fidentity-mgt%2Forg.wso2.carbon.identity.mgt.endpoint.util%2Fsrc%2Fmain%2Fjava%2Forg%2Fwso2%2Fcarbon%2Fidentity%2Fmgt%2Fendpoint%2Futil%2FIdentityManagementEndpointUtil.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2#diff-Y29tcG9uZW50cy9pZGVudGl0eS1tZ3Qvb3JnLndzbzIuY2FyYm9uLmlkZW50aXR5Lm1ndC5lbmRwb2ludC51dGlsL3NyYy9tYWluL2phdmEvb3JnL3dzbzIvY2FyYm9uL2lkZW50aXR5L21ndC9lbmRwb2ludC91dGlsL0lkZW50aXR5TWFuYWdlbWVudEVuZHBvaW50VXRpbC5qYXZh) | 81.81% | [1 Missing and 1 partial :warning: ](https://app.codecov.io/gh/wso2/carbon-identity-framework/pull/6721?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2) |
| [.../util/client/AuthenticatorDataRetrievalClient.java](https://app.codecov.io/gh/wso2/carbon-identity-framework/pull/6721?src=pr&el=tree&filepath=components%2Fidentity-mgt%2Forg.wso2.carbon.identity.mgt.endpoint.util%2Fsrc%2Fmain%2Fjava%2Forg%2Fwso2%2Fcarbon%2Fidentity%2Fmgt%2Fendpoint%2Futil%2Fclient%2FAuthenticatorDataRetrievalClient.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2#diff-Y29tcG9uZW50cy9pZGVudGl0eS1tZ3Qvb3JnLndzbzIuY2FyYm9uLmlkZW50aXR5Lm1ndC5lbmRwb2ludC51dGlsL3NyYy9tYWluL2phdmEvb3JnL3dzbzIvY2FyYm9uL2lkZW50aXR5L21ndC9lbmRwb2ludC91dGlsL2NsaWVudC9BdXRoZW50aWNhdG9yRGF0YVJldHJpZXZhbENsaWVudC5qYXZh) | 75.00% | [0 Missing and 2 partials :warning: ](https://app.codecov.io/gh/wso2/carbon-identity-framework/pull/6721?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2) |
| ... and [4 more](https://app.codecov.io/gh/wso2/carbon-identity-framework/pull/6721?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2) | |

:x: Your patch status has failed because the patch coverage (24.20%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the [target](https://docs.codecov.com/docs/commit-status#target) coverage.

<details><summary>Additional details and impacted files</summary>


```diff
@@             Coverage Diff              @@
##             master    #6721      +/-   ##
============================================
- Coverage     47.73%   47.60%   -0.13%     
+ Complexity    16806    16785      -21     
============================================
  Files          1937     1937              
  Lines        113989   114052      +63     
  Branches      21504    21452      -52     
============================================
- Hits          54409    54294     -115     
- Misses        52291    52506     +215     
+ Partials       7289     7252      -37     
```

| [Flag](https://app.codecov.io/gh/wso2/carbon-identity-framework/pull/6721/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2) | Coverage Δ | |
|---|---|---|
| [unit](https://app.codecov.io/gh/wso2/carbon-identity-framework/pull/6721/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2) | `32.86% <24.20%> (+0.02%)` | :arrow_up: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2#carryforward-flags-in-the-pull-request-comment) to find out more.

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/wso2/carbon-identity-framework/pull/6721?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2).

<details><summary> :rocket: New features to boost your workflow: </summary>

- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
author_association: NONE
user: login: jenkins-is-staging
created_at: 2025-05-21T14:32:26Z
body: PR builder started 
Link: https://github.com/wso2/product-is/actions/runs/15164987580
author_association: NONE
user: login: jenkins-is-staging
created_at: 2025-05-21T18:01:31Z
body: PR builder completed 
Link: https://github.com/wso2/product-is/actions/runs/15164987580 
Status: **cancelled**
author_association: NONE
user: login: jenkins-is-staging
created_at: 2025-05-21T18:04:20Z
body: PR builder started 
Link: https://github.com/wso2/product-is/actions/runs/15164987580
author_association: NONE
user: login: jenkins-is-staging
created_at: 2025-05-21T19:58:34Z
body: PR builder completed 
Link: https://github.com/wso2/product-is/actions/runs/15164987580 
Status: **success**
author_association: NONE
user: login: sonarqubecloud[bot]
created_at: 2025-05-22T09:31:54Z
body: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=wso2_carbon-identity-framework&pullRequest=6721) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [6 New issues](https://sonarcloud.io/project/issues?id=wso2_carbon-identity-framework&pullRequest=6721&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=wso2_carbon-identity-framework&pullRequest=6721&issueStatuses=ACCEPTED)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=wso2_carbon-identity-framework&pullRequest=6721&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=wso2_carbon-identity-framework&pullRequest=6721&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.8% Duplication on New Code](https://sonarcloud.io/component_measures?id=wso2_carbon-identity-framework&pullRequest=6721&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=wso2_carbon-identity-framework&pullRequest=6721)


author_association: NONE