|
|
|
@ -21,6 +21,7 @@ import org.apache.commons.logging.Log;
|
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceTypeIdentifier;
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementServiceComponent;
|
|
|
|
@ -44,8 +45,10 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
|
|
|
|
|
|
|
|
|
|
public void addDeviceManagementProvider(DeviceManagementService provider) throws DeviceManagementException {
|
|
|
|
|
String deviceType = provider.getType();
|
|
|
|
|
String tenantDomain = provider.getProviderTenantDomain();
|
|
|
|
|
boolean isSharedWithAllTenants = provider.isSharedWithAllTenants();
|
|
|
|
|
|
|
|
|
|
ProvisioningConfig provisioningConfig = provider.getProvisioningConfig();
|
|
|
|
|
String tenantDomain = provisioningConfig.getProviderTenantDomain();
|
|
|
|
|
boolean isSharedWithAllTenants = provisioningConfig.isSharedWithAllTenants();
|
|
|
|
|
int tenantId = DeviceManagerUtil.getTenantId(tenantDomain);
|
|
|
|
|
if (tenantId == -1) {
|
|
|
|
|
throw new DeviceManagementException("No tenant available for tenant domain " + tenantDomain);
|
|
|
|
@ -57,7 +60,7 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
|
|
|
|
|
provider.init();
|
|
|
|
|
DeviceManagerUtil.registerDeviceType(deviceType, tenantId, isSharedWithAllTenants);
|
|
|
|
|
DeviceManagementDataHolder.getInstance().setRequireDeviceAuthorization(deviceType,
|
|
|
|
|
provider.getDeviceManager().requireDeviceAuthorization());
|
|
|
|
|
provider.getDeviceManager().requireDeviceAuthorization());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
@ -75,13 +78,15 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void removeDeviceManagementProvider(DeviceManagementService provider) throws DeviceManagementException {
|
|
|
|
|
String deviceTypeName=provider.getType();
|
|
|
|
|
if(provider.isSharedWithAllTenants()){
|
|
|
|
|
DeviceTypeIdentifier deviceTypeIdentifier =new DeviceTypeIdentifier(deviceTypeName);
|
|
|
|
|
String deviceTypeName = provider.getType();
|
|
|
|
|
|
|
|
|
|
ProvisioningConfig provisioningConfig = provider.getProvisioningConfig();
|
|
|
|
|
if (provisioningConfig.isSharedWithAllTenants()) {
|
|
|
|
|
DeviceTypeIdentifier deviceTypeIdentifier = new DeviceTypeIdentifier(deviceTypeName);
|
|
|
|
|
providers.remove(deviceTypeIdentifier);
|
|
|
|
|
}else{
|
|
|
|
|
int providerTenantId=DeviceManagerUtil.getTenantId(provider.getProviderTenantDomain());
|
|
|
|
|
DeviceTypeIdentifier deviceTypeIdentifier =new DeviceTypeIdentifier(deviceTypeName, providerTenantId);
|
|
|
|
|
} else {
|
|
|
|
|
int providerTenantId = DeviceManagerUtil.getTenantId(provisioningConfig.getProviderTenantDomain());
|
|
|
|
|
DeviceTypeIdentifier deviceTypeIdentifier = new DeviceTypeIdentifier(deviceTypeName, providerTenantId);
|
|
|
|
|
providers.remove(deviceTypeIdentifier);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -113,15 +118,17 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
|
|
|
|
|
for (DeviceManagementService provider : providers.values()) {
|
|
|
|
|
try {
|
|
|
|
|
provider.init();
|
|
|
|
|
int tenantId=DeviceManagerUtil.getTenantId(provider.getProviderTenantDomain());
|
|
|
|
|
DeviceManagerUtil.registerDeviceType(provider.getType(), tenantId, provider.isSharedWithAllTenants());
|
|
|
|
|
|
|
|
|
|
ProvisioningConfig provisioningConfig = provider.getProvisioningConfig();
|
|
|
|
|
int tenantId = DeviceManagerUtil.getTenantId(provisioningConfig.getProviderTenantDomain());
|
|
|
|
|
DeviceManagerUtil.registerDeviceType(provider.getType(), tenantId, provisioningConfig.isSharedWithAllTenants());
|
|
|
|
|
//TODO:
|
|
|
|
|
//This is a temporory fix.
|
|
|
|
|
//windows and IOS cannot resolve user info by extracting certs
|
|
|
|
|
//until fix that, use following variable to enable and disable of checking user authorization.
|
|
|
|
|
|
|
|
|
|
DeviceManagementDataHolder.getInstance().setRequireDeviceAuthorization(provider.getType(),
|
|
|
|
|
provider.getDeviceManager().requireDeviceAuthorization());
|
|
|
|
|
provider.getDeviceManager().requireDeviceAuthorization());
|
|
|
|
|
} catch (Throwable e) {
|
|
|
|
|
/* Throwable is caught intentionally as failure of one plugin - due to invalid start up parameters,
|
|
|
|
|
etc - should not block the initialization of other device management providers */
|
|
|
|
|