diff --git a/components/org.wso2.carbon.identity.api.user.application/org.wso2.carbon.identity.api.user.application.common/pom.xml b/components/org.wso2.carbon.identity.api.user.application/org.wso2.carbon.identity.api.user.application.common/pom.xml
index f90b9a300..57dfaafcd 100644
--- a/components/org.wso2.carbon.identity.api.user.application/org.wso2.carbon.identity.api.user.application.common/pom.xml
+++ b/components/org.wso2.carbon.identity.api.user.application/org.wso2.carbon.identity.api.user.application.common/pom.xml
@@ -38,5 +38,10 @@
org.wso2.carbon.identity.application.mgt
provided
+
+ org.wso2.carbon.identity.organization.management
+ org.wso2.carbon.identity.organization.management.application
+ provided
+
diff --git a/components/org.wso2.carbon.identity.api.user.application/org.wso2.carbon.identity.api.user.application.common/src/main/java/org/wso2/carbon/identity/api/user/application/common/ApplicationServiceHolder.java b/components/org.wso2.carbon.identity.api.user.application/org.wso2.carbon.identity.api.user.application.common/src/main/java/org/wso2/carbon/identity/api/user/application/common/ApplicationServiceHolder.java
index 9195a3fde..421900634 100644
--- a/components/org.wso2.carbon.identity.api.user.application/org.wso2.carbon.identity.api.user.application.common/src/main/java/org/wso2/carbon/identity/api/user/application/common/ApplicationServiceHolder.java
+++ b/components/org.wso2.carbon.identity.api.user.application/org.wso2.carbon.identity.api.user.application.common/src/main/java/org/wso2/carbon/identity/api/user/application/common/ApplicationServiceHolder.java
@@ -19,12 +19,14 @@
package org.wso2.carbon.identity.api.user.application.common;
import org.wso2.carbon.identity.application.mgt.DiscoverableApplicationManager;
+import org.wso2.carbon.identity.organization.management.application.OrgApplicationManager;
/**
* Application management service holder.
*/
public class ApplicationServiceHolder {
+ private static OrgApplicationManager orgApplicationManager;
private static DiscoverableApplicationManager discoverableApplicationManager;
/**
@@ -47,4 +49,24 @@ public static void setDiscoverableApplicationManager(DiscoverableApplicationMana
ApplicationServiceHolder.discoverableApplicationManager = discoverableApplicationManager;
}
+
+ /**
+ * Get organization application management service.
+ *
+ * @return OrgApplicationManager
+ */
+ public static OrgApplicationManager getOrgApplicationManager() {
+
+ return orgApplicationManager;
+ }
+
+ /**
+ * Set organization application management service.
+ *
+ * @param orgApplicationManager
+ */
+ public static void setOrgApplicationManager(OrgApplicationManager orgApplicationManager) {
+
+ ApplicationServiceHolder.orgApplicationManager = orgApplicationManager;
+ }
}
diff --git a/components/org.wso2.carbon.identity.api.user.application/org.wso2.carbon.identity.api.user.application.common/src/main/java/org/wso2/carbon/identity/api/user/application/common/factory/OrganizationManagementOSGIServiceFactory.java b/components/org.wso2.carbon.identity.api.user.application/org.wso2.carbon.identity.api.user.application.common/src/main/java/org/wso2/carbon/identity/api/user/application/common/factory/OrganizationManagementOSGIServiceFactory.java
new file mode 100644
index 000000000..8129c35ab
--- /dev/null
+++ b/components/org.wso2.carbon.identity.api.user.application/org.wso2.carbon.identity.api.user.application.common/src/main/java/org/wso2/carbon/identity/api/user/application/common/factory/OrganizationManagementOSGIServiceFactory.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.carbon.identity.api.user.application.common.factory;
+
+import org.springframework.beans.factory.config.AbstractFactoryBean;
+import org.wso2.carbon.context.PrivilegedCarbonContext;
+import org.wso2.carbon.identity.organization.management.application.OrgApplicationManager;
+
+/**
+ * Factory Beans serves as a factory for creating other beans within the IOC container. This factory bean is used to
+ * instantiate the OrganizationManagementOSGIServiceFactory class and used to get OrganizationManagementOSGIService OSGI
+ * service.
+ */
+public class OrganizationManagementOSGIServiceFactory extends AbstractFactoryBean {
+
+ private OrgApplicationManager orgApplicationManager;
+
+ @Override
+ public Class> getObjectType() {
+
+ return null;
+ }
+
+ @Override
+ protected OrgApplicationManager createInstance() throws Exception {
+
+ if (this.orgApplicationManager == null) {
+ OrgApplicationManager applicationManagementService = (OrgApplicationManager)
+ PrivilegedCarbonContext.getThreadLocalCarbonContext()
+ .getOSGiService(OrgApplicationManager.class, null);
+ if (applicationManagementService != null) {
+ this.orgApplicationManager = applicationManagementService;
+ } else {
+ throw new Exception("Unable to retrieve OrgApplicationManager service.");
+ }
+ }
+ return this.orgApplicationManager;
+ }
+}
diff --git a/components/org.wso2.carbon.identity.api.user.application/org.wso2.carbon.identity.rest.api.user.application.v1/pom.xml b/components/org.wso2.carbon.identity.api.user.application/org.wso2.carbon.identity.rest.api.user.application.v1/pom.xml
index 45e0e9224..aa3d48151 100644
--- a/components/org.wso2.carbon.identity.api.user.application/org.wso2.carbon.identity.rest.api.user.application.v1/pom.xml
+++ b/components/org.wso2.carbon.identity.api.user.application/org.wso2.carbon.identity.rest.api.user.application.v1/pom.xml
@@ -180,5 +180,15 @@
org.wso2.carbon.identity.core
provided
+
+ org.wso2.carbon.identity.organization.management.core
+ org.wso2.carbon.identity.organization.management.service
+ provided
+
+
+ org.wso2.carbon.identity.organization.management
+ org.wso2.carbon.identity.organization.management.application
+ provided
+
diff --git a/components/org.wso2.carbon.identity.api.user.application/org.wso2.carbon.identity.rest.api.user.application.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/application/v1/core/ApplicationService.java b/components/org.wso2.carbon.identity.api.user.application/org.wso2.carbon.identity.rest.api.user.application.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/application/v1/core/ApplicationService.java
index 056e8f30d..9ac7b0231 100644
--- a/components/org.wso2.carbon.identity.api.user.application/org.wso2.carbon.identity.rest.api.user.application.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/application/v1/core/ApplicationService.java
+++ b/components/org.wso2.carbon.identity.api.user.application/org.wso2.carbon.identity.rest.api.user.application.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/application/v1/core/ApplicationService.java
@@ -34,6 +34,8 @@
import org.wso2.carbon.identity.core.model.FilterTreeBuilder;
import org.wso2.carbon.identity.core.model.Node;
import org.wso2.carbon.identity.core.util.IdentityTenantUtil;
+import org.wso2.carbon.identity.organization.management.service.exception.OrganizationManagementException;
+import org.wso2.carbon.identity.organization.management.service.util.OrganizationManagementUtil;
import org.wso2.carbon.identity.rest.api.user.application.v1.core.function.ApplicationBasicInfoToApiModel;
import org.wso2.carbon.identity.rest.api.user.application.v1.model.ApplicationListResponse;
import org.wso2.carbon.identity.rest.api.user.application.v1.model.ApplicationResponse;
@@ -108,11 +110,9 @@ public ApplicationListResponse getApplications(String attributes, Integer limit,
String tenantDomain = IdentityTenantUtil.resolveTenantDomain();
String filterFormatted = buildFilter(filter);
try {
- List applicationBasicInfos = ApplicationServiceHolder
- .getDiscoverableApplicationManager().getDiscoverableApplicationBasicInfo(limit, offset,
- filterFormatted, sortOrder, sortBy, tenantDomain);
- int totalApps = ApplicationServiceHolder.getDiscoverableApplicationManager()
- .getCountOfDiscoverableApplications(filterFormatted, tenantDomain);
+ List applicationBasicInfos = getDiscoverableApplicationBasicInfo(limit, offset,
+ filterFormatted, sortOrder, sortBy, tenantDomain);
+ int totalApps = getCountOfDiscoverableApplications(filterFormatted, tenantDomain);
return buildApplicationListResponse(limit, offset, totalApps, applicationBasicInfos);
} catch (IdentityApplicationManagementException e) {
@@ -123,6 +123,38 @@ public ApplicationListResponse getApplications(String attributes, Integer limit,
}
}
+ private List getDiscoverableApplicationBasicInfo(int limit, int offset, String filter,
+ String sortOrder, String sortBy,
+ String tenantDomain)
+ throws IdentityApplicationManagementException {
+
+ try {
+ if (OrganizationManagementUtil.isOrganization(tenantDomain)) {
+ return ApplicationServiceHolder.getOrgApplicationManager().getDiscoverableSharedApplicationBasicInfo(
+ limit, offset, filter, sortOrder, sortBy, tenantDomain);
+ }
+ return ApplicationServiceHolder.getDiscoverableApplicationManager().getDiscoverableApplicationBasicInfo(
+ limit, offset, filter, sortOrder, sortBy, tenantDomain);
+ } catch (OrganizationManagementException e) {
+ throw new IdentityApplicationManagementException(e.getMessage(), e);
+ }
+ }
+
+ private int getCountOfDiscoverableApplications(String filter, String tenantDomain)
+ throws IdentityApplicationManagementException {
+
+ try {
+ if (OrganizationManagementUtil.isOrganization(tenantDomain)) {
+ return ApplicationServiceHolder.getOrgApplicationManager()
+ .getCountOfDiscoverableSharedApplications(filter, tenantDomain);
+ }
+ return ApplicationServiceHolder.getDiscoverableApplicationManager()
+ .getCountOfDiscoverableApplications(filter, tenantDomain);
+ } catch (OrganizationManagementException e) {
+ throw new IdentityApplicationManagementException(e.getMessage(), e);
+ }
+ }
+
private ApplicationResponse buildApplicationResponse(ApplicationBasicInfo applicationBasicInfo) {
return new ApplicationBasicInfoToApiModel().apply(applicationBasicInfo);
diff --git a/components/org.wso2.carbon.identity.api.user.application/org.wso2.carbon.identity.rest.api.user.application.v1/src/main/resources/META-INF/cxf/application-user-v1-cxf.xml b/components/org.wso2.carbon.identity.api.user.application/org.wso2.carbon.identity.rest.api.user.application.v1/src/main/resources/META-INF/cxf/application-user-v1-cxf.xml
index e3e295d57..675278ed0 100644
--- a/components/org.wso2.carbon.identity.api.user.application/org.wso2.carbon.identity.rest.api.user.application.v1/src/main/resources/META-INF/cxf/application-user-v1-cxf.xml
+++ b/components/org.wso2.carbon.identity.api.user.application/org.wso2.carbon.identity.rest.api.user.application.v1/src/main/resources/META-INF/cxf/application-user-v1-cxf.xml
@@ -24,7 +24,10 @@
+
+
diff --git a/pom.xml b/pom.xml
index 213012875..9fc23fc3d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -295,6 +295,11 @@
org.wso2.carbon.extension.identity.verification.provider
${identity.verification.version}
+
+ org.wso2.carbon.identity.organization.management
+ org.wso2.carbon.identity.organization.management.application
+ ${identity.organization.management.version}
+
org.wso2.carbon.extension.identity.verification
org.wso2.carbon.extension.identity.verification.mgt
@@ -491,6 +496,7 @@
2.6.0.wso2v1
findbugs-exclude-filter.xml
1.0.13
+ 1.4.47