|
|
|
@ -37,14 +37,21 @@ import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
|
|
|
|
|
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
|
|
|
|
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.InputValidationException;
|
|
|
|
|
import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService;
|
|
|
|
|
import org.wso2.carbon.identity.user.store.count.AbstractCountRetrieverFactory;
|
|
|
|
|
import org.wso2.carbon.identity.user.store.count.UserStoreCountRetriever;
|
|
|
|
|
import org.wso2.carbon.identity.user.store.count.exception.UserStoreCounterException;
|
|
|
|
|
import org.wso2.carbon.identity.user.store.count.jdbc.JDBCCountRetrieverFactory;
|
|
|
|
|
import org.wso2.carbon.identity.user.store.count.jdbc.internal.InternalCountRetrieverFactory;
|
|
|
|
|
import org.wso2.carbon.policy.mgt.common.PolicyMonitoringTaskException;
|
|
|
|
|
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
|
|
|
|
import org.wso2.carbon.policy.mgt.core.task.TaskScheduleService;
|
|
|
|
|
import org.wso2.carbon.registry.core.service.RegistryService;
|
|
|
|
|
import org.wso2.carbon.user.api.AuthorizationManager;
|
|
|
|
|
import org.wso2.carbon.user.api.RealmConfiguration;
|
|
|
|
|
import org.wso2.carbon.user.api.UserRealm;
|
|
|
|
|
import org.wso2.carbon.user.api.UserStoreException;
|
|
|
|
|
import org.wso2.carbon.user.api.UserStoreManager;
|
|
|
|
|
import org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager;
|
|
|
|
|
import org.wso2.carbon.user.core.service.RealmService;
|
|
|
|
|
|
|
|
|
|
import javax.ws.rs.core.MediaType;
|
|
|
|
@ -106,6 +113,32 @@ public class DeviceMgtAPIUtils {
|
|
|
|
|
return deviceManagementProviderService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static UserStoreCountRetriever getUserStoreCountRetrieverService()
|
|
|
|
|
throws UserStoreCounterException {
|
|
|
|
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
|
|
|
List<Object> countRetrieverFactories = ctx.getOSGiServices(AbstractCountRetrieverFactory.class, null);
|
|
|
|
|
RealmService realmService = (RealmService) ctx.getOSGiService(RealmService.class, null);
|
|
|
|
|
RealmConfiguration realmConfiguration = realmService.getBootstrapRealmConfiguration();
|
|
|
|
|
String userStoreType;
|
|
|
|
|
//Ignoring Sonar warning as getUserStoreClass() returning string name of the class. So cannot use 'instanceof'.
|
|
|
|
|
if (JDBCUserStoreManager.class.getName().equals(realmConfiguration.getUserStoreClass())) {
|
|
|
|
|
userStoreType = JDBCCountRetrieverFactory.JDBC;
|
|
|
|
|
} else {
|
|
|
|
|
userStoreType = InternalCountRetrieverFactory.INTERNAL;
|
|
|
|
|
}
|
|
|
|
|
AbstractCountRetrieverFactory countRetrieverFactory = null;
|
|
|
|
|
for (Object countRetrieverFactoryObj : countRetrieverFactories) {
|
|
|
|
|
countRetrieverFactory = (AbstractCountRetrieverFactory) countRetrieverFactoryObj;
|
|
|
|
|
if (userStoreType.equals(countRetrieverFactory.getCounterType())) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (countRetrieverFactory == null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return countRetrieverFactory.buildCountRetriever(realmConfiguration);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static DeviceAccessAuthorizationService getDeviceAccessAuthorizationService() {
|
|
|
|
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
|
|
|
DeviceAccessAuthorizationService deviceAccessAuthorizationService =
|
|
|
|
|