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

Add console role listener #7416

Merged
merged 3 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -88,6 +88,14 @@
<groupId>org.wso2.carbon.identity.organization.management</groupId>
<artifactId>org.wso2.carbon.identity.organization.management.application</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.api.resource.mgt</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.api.resource.collection.mgt</artifactId>
</dependency>
<!-- To fix travis build -->
<dependency>
<groupId>xalan</groupId>
Expand Down Expand Up @@ -141,7 +149,8 @@
org.wso2.carbon.identity.role.v2.mgt.core.*; version="${carbon.identity.framework.imp.pkg.version.range}",
org.wso2.carbon.identity.organization.management.service.*; version="${identity.org.mgt.core.version.range}",
org.wso2.carbon.identity.organization.management.application.*; version="${identity.org.mgt.application.version.range}",
org.wso2.carbon.identity.api.resource.mgt.*; version="${carbon.identity.framework.imp.pkg.version.range}"
org.wso2.carbon.identity.api.resource.mgt.*; version="${carbon.identity.framework.imp.pkg.version.range}",
org.wso2.carbon.identity.api.resource.collection.mgt.*; version="${carbon.identity.framework.imp.pkg.version.range}"
</import.package>
<dsannotations>*</dsannotations>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.wso2.identity.apps.common.internal;

import org.wso2.carbon.identity.api.resource.collection.mgt.APIResourceCollectionManager;
import org.wso2.carbon.identity.api.resource.mgt.APIResourceManager;
import org.wso2.carbon.identity.application.mgt.ApplicationManagementService;
import org.wso2.carbon.identity.oauth.OAuthAdminServiceImpl;
Expand Down Expand Up @@ -47,6 +48,7 @@ public class AppsCommonDataHolder {
private RoleManagementService roleManagementService;

private APIResourceManager apiResourceManager;
private APIResourceCollectionManager apiResourceCollectionManager;

private Set<String> systemAppConsumerKeys = new HashSet<>();

Expand Down Expand Up @@ -222,6 +224,26 @@ public APIResourceManager getAPIResourceManager() {
return apiResourceManager;
}

/**
* Set API resource collection manager.
*
* @param apiResourceCollectionManager APIResourceCollectionManager.
*/
public void setAPIResourceCollectionManager(APIResourceCollectionManager apiResourceCollectionManager) {

this.apiResourceCollectionManager = apiResourceCollectionManager;
}

/**
* Get API resource collection manager.
*
* @return apiResourceCollectionManager.
*/
public APIResourceCollectionManager getApiResourceCollectionManager() {

return apiResourceCollectionManager;
}


/**
* Set default applications.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.osgi.service.component.annotations.ReferencePolicy;
import org.wso2.carbon.CarbonConstants;
import org.wso2.carbon.core.ServerStartupObserver;
import org.wso2.carbon.identity.api.resource.collection.mgt.APIResourceCollectionManager;
import org.wso2.carbon.identity.api.resource.mgt.APIResourceManager;
import org.wso2.carbon.identity.application.common.IdentityApplicationManagementException;
import org.wso2.carbon.identity.application.common.model.InboundAuthenticationRequestConfig;
Expand All @@ -48,6 +49,7 @@
import org.wso2.identity.apps.common.listner.AppPortalOAuthAppMgtListener;
import org.wso2.identity.apps.common.listner.AppPortalRoleManagementListener;
import org.wso2.identity.apps.common.listner.AppPortalTenantMgtListener;
import org.wso2.identity.apps.common.listner.ConsoleRoleListener;
import org.wso2.identity.apps.common.util.AppPortalUtils;

import java.util.HashSet;
Expand Down Expand Up @@ -109,6 +111,10 @@ protected void activate(BundleContext bundleContext) {
RoleManagementListener roleManagementListener = new AppPortalRoleManagementListener(true);
bundleContext.registerService(RoleManagementListener.class.getName(), roleManagementListener, null);
log.debug("AppPortalRoleManagementListener registered successfully.");

RoleManagementListener consoleRoleListener = new ConsoleRoleListener();
bundleContext.registerService(RoleManagementListener.class.getName(), consoleRoleListener, null);
log.debug("ConsoleRoleListener registered successfully.");
}

if (!CarbonConstants.ENABLE_LEGACY_AUTHZ_RUNTIME) {
Expand Down Expand Up @@ -266,6 +272,22 @@ protected void unsetAPIResourceManager(APIResourceManager apiResourceManager) {
AppsCommonDataHolder.getInstance().setAPIResourceManager(null);
}

@Reference(
name = "api.resource.collection.mgt.service",
service = APIResourceCollectionManager.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
unbind = "unsetAPIResourceCollectionManager")
protected void setAPIResourceManager(APIResourceCollectionManager apiResourceCollectionManager) {

AppsCommonDataHolder.getInstance().setAPIResourceCollectionManager(apiResourceCollectionManager);
}

protected void unsetAPIResourceCollectionManager(APIResourceCollectionManager apiResourceCollectionManager) {

AppsCommonDataHolder.getInstance().setAPIResourceCollectionManager(null);
}

private boolean skipPortalInitialization() {

return System.getProperty(SYSTEM_PROP_SKIP_SERVER_INITIALIZATION) != null;
Expand Down
Loading
Loading