Skip to content

Commit

Permalink
Merge pull request wso2#5267 from ShanChathusanda93/permission-provid…
Browse files Browse the repository at this point in the history
…er-npe-branch

Fix NPE when calling the Application Permission Provider from the migration client
  • Loading branch information
ShanChathusanda93 authored Dec 15, 2023
2 parents dfac1f8 + 0ea270e commit f561621
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.wso2.carbon.identity.application.common.model.User;
import org.wso2.carbon.identity.application.mgt.dao.ApplicationDAO;
import org.wso2.carbon.identity.application.mgt.internal.ApplicationManagementServiceComponentHolder;
import org.wso2.carbon.identity.application.mgt.provider.RegistryBasedApplicationPermissionProvider;
import org.wso2.carbon.identity.base.IdentityException;
import org.wso2.carbon.identity.central.log.mgt.utils.LoggerUtils;
import org.wso2.carbon.identity.core.ServiceURLBuilder;
Expand Down Expand Up @@ -443,6 +444,16 @@ public static void storePermissions(String applicationName, String username,
PermissionsAndRoleConfig permissionsConfig)
throws IdentityApplicationManagementException {

/*
There can be places like migration client, where this method is called before initializing the
ApplicationMgtService from the OSGi environment. In such places, if we need to initialize the
ApplicationPermissionProvider, we need to check the provider and initialize a default one. In this case
the default provider is RegistryBasedApplicationPermissionProvider.
*/
if (ApplicationManagementServiceComponentHolder.getInstance().getApplicationPermissionProvider() == null) {
ApplicationManagementServiceComponentHolder.getInstance()
.setApplicationPermissionProvider(new RegistryBasedApplicationPermissionProvider());
}
ApplicationManagementServiceComponentHolder.getInstance().getApplicationPermissionProvider()
.storePermissions(applicationName, permissionsConfig);
}
Expand Down

0 comments on commit f561621

Please sign in to comment.