Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New services to derive whether app is shared to a given org / get main app id #260

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,36 @@ default ServiceProvider resolveSharedApplicationByMainAppUUID(String mainAppUUID
return null;
}

/**
* Check whether the application is shared with the given organization.
*
* @param mainAppId UUID of the main application.
* @param ownerOrgId Identifier of the organization owning the application.
* @param sharedOrgId Identifier of the organization which checking whether app is shared or not.
* @return True if the application is shared with the given organization.
* @throws OrganizationManagementException If errors occurred when checking whether the application is shared
* with the given organization.
*/
default boolean isApplicationSharedWithGivenOrganization(String mainAppId, String ownerOrgId, String sharedOrgId)
throws OrganizationManagementException {

return false;
}

/**
* Get the main application id for given shared application.
*
* @param sharedAppId Shared application id.
* @param sharedOrgId Organization id of the shared application.
* @return Main application id.
* @throws OrganizationManagementException If errors occurred when getting the main application id.
*/
default String getMainApplicationIdForGivenSharedApp(String sharedAppId, String sharedOrgId)
throws OrganizationManagementException {

return null;
}

/**
* Share the application to an organization.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import org.wso2.carbon.identity.organization.management.application.dao.OrgApplicationMgtDAO;
import org.wso2.carbon.identity.organization.management.application.internal.OrgApplicationMgtDataHolder;
import org.wso2.carbon.identity.organization.management.application.listener.ApplicationSharingManagerListener;
import org.wso2.carbon.identity.organization.management.application.model.MainApplicationDO;
import org.wso2.carbon.identity.organization.management.application.model.SharedApplication;
import org.wso2.carbon.identity.organization.management.application.model.SharedApplicationDO;
import org.wso2.carbon.identity.organization.management.service.OrganizationManager;
Expand Down Expand Up @@ -397,6 +398,23 @@ public ServiceProvider resolveSharedApplicationByMainAppUUID(String mainAppUUID,
}
}

@Override
public boolean isApplicationSharedWithGivenOrganization(String mainAppId, String ownerOrgId, String sharedOrgId)
throws OrganizationManagementException {

return resolveSharedApp(mainAppId, ownerOrgId, sharedOrgId).isPresent();
}

@Override
public String getMainApplicationIdForGivenSharedApp(String sharedAppId, String sharedOrgId)
throws OrganizationManagementException {

return getOrgApplicationMgtDAO()
.getMainApplication(sharedAppId, sharedOrgId)
.map(MainApplicationDO::getMainApplicationId)
.orElse(null);
}

/**
* Retrieve the application ({@link ServiceProvider}) for the given identifier and the tenant domain.
*
Expand Down
Loading