|
|
@ -31,15 +31,14 @@ import org.wso2.carbon.device.mgt.common.TransactionManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
|
|
|
|
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
|
|
|
|
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
|
|
|
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
|
|
|
|
import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
|
|
|
|
import org.wso2.carbon.device.mgt.core.DeviceManagementPluginRepository;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig;
|
|
|
|
import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig;
|
|
|
|
import org.wso2.carbon.device.mgt.core.app.mgt.oauth.ServiceAuthenticator;
|
|
|
|
import org.wso2.carbon.device.mgt.core.app.mgt.oauth.ServiceAuthenticator;
|
|
|
|
import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
|
|
|
|
import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
|
|
|
|
import org.wso2.carbon.device.mgt.core.config.identity.IdentityConfigurations;
|
|
|
|
import org.wso2.carbon.device.mgt.core.config.identity.IdentityConfigurations;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dao.*;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dao.*;
|
|
|
|
import org.wso2.carbon.device.mgt.core.internal.PluginInitializationListener;
|
|
|
|
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
|
|
|
|
import org.wso2.carbon.identity.oauth.stub.OAuthAdminServiceException;
|
|
|
|
import org.wso2.carbon.identity.oauth.stub.OAuthAdminServiceException;
|
|
|
|
import org.wso2.carbon.identity.oauth.stub.OAuthAdminServiceStub;
|
|
|
|
import org.wso2.carbon.identity.oauth.stub.OAuthAdminServiceStub;
|
|
|
|
import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO;
|
|
|
|
import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO;
|
|
|
@ -52,13 +51,11 @@ import java.util.List;
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Implements Application Manager interface
|
|
|
|
* Implements Application Manager interface
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class ApplicationManagerProviderServiceImpl implements ApplicationManagementProviderService,
|
|
|
|
public class ApplicationManagerProviderServiceImpl implements ApplicationManagementProviderService {
|
|
|
|
PluginInitializationListener {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ConfigurationContext configCtx;
|
|
|
|
private ConfigurationContext configCtx;
|
|
|
|
private ServiceAuthenticator authenticator;
|
|
|
|
private ServiceAuthenticator authenticator;
|
|
|
|
private String oAuthAdminServiceUrl;
|
|
|
|
private String oAuthAdminServiceUrl;
|
|
|
|
private DeviceManagementPluginRepository pluginRepository;
|
|
|
|
|
|
|
|
private DeviceDAO deviceDAO;
|
|
|
|
private DeviceDAO deviceDAO;
|
|
|
|
private ApplicationDAO applicationDAO;
|
|
|
|
private ApplicationDAO applicationDAO;
|
|
|
|
private ApplicationMappingDAO applicationMappingDAO;
|
|
|
|
private ApplicationMappingDAO applicationMappingDAO;
|
|
|
@ -66,8 +63,7 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
|
|
|
|
private static final String GET_APP_LIST_URL = "store/apis/assets/mobileapp?domain=carbon.super&page=1";
|
|
|
|
private static final String GET_APP_LIST_URL = "store/apis/assets/mobileapp?domain=carbon.super&page=1";
|
|
|
|
private static final Log log = LogFactory.getLog(ApplicationManagerProviderServiceImpl.class);
|
|
|
|
private static final Log log = LogFactory.getLog(ApplicationManagerProviderServiceImpl.class);
|
|
|
|
|
|
|
|
|
|
|
|
public ApplicationManagerProviderServiceImpl(AppManagementConfig appManagementConfig,
|
|
|
|
public ApplicationManagerProviderServiceImpl(AppManagementConfig appManagementConfig) {
|
|
|
|
DeviceManagementPluginRepository pluginRepository) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IdentityConfigurations identityConfig = DeviceConfigurationManager.getInstance().getDeviceManagementConfig().
|
|
|
|
IdentityConfigurations identityConfig = DeviceConfigurationManager.getInstance().getDeviceManagementConfig().
|
|
|
|
getDeviceManagementConfigRepository().getIdentityConfigurations();
|
|
|
|
getDeviceManagementConfigRepository().getIdentityConfigurations();
|
|
|
@ -81,14 +77,12 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
|
|
|
|
throw new IllegalArgumentException("Error occurred while initializing Axis2 Configuration Context. " +
|
|
|
|
throw new IllegalArgumentException("Error occurred while initializing Axis2 Configuration Context. " +
|
|
|
|
"Please check if an appropriate axis2.xml is provided", e);
|
|
|
|
"Please check if an appropriate axis2.xml is provided", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.pluginRepository = pluginRepository;
|
|
|
|
|
|
|
|
this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
|
|
|
|
this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
|
|
|
|
this.applicationDAO = DeviceManagementDAOFactory.getApplicationDAO();
|
|
|
|
this.applicationDAO = DeviceManagementDAOFactory.getApplicationDAO();
|
|
|
|
this.applicationMappingDAO = DeviceManagementDAOFactory.getApplicationMappingDAO();
|
|
|
|
this.applicationMappingDAO = DeviceManagementDAOFactory.getApplicationMappingDAO();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ApplicationManagerProviderServiceImpl(DeviceManagementPluginRepository pluginRepository) {
|
|
|
|
ApplicationManagerProviderServiceImpl() {
|
|
|
|
this.pluginRepository = pluginRepository;
|
|
|
|
|
|
|
|
this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
|
|
|
|
this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
|
|
|
|
this.applicationDAO = DeviceManagementDAOFactory.getApplicationDAO();
|
|
|
|
this.applicationDAO = DeviceManagementDAOFactory.getApplicationDAO();
|
|
|
|
this.applicationMappingDAO = DeviceManagementDAOFactory.getApplicationMappingDAO();
|
|
|
|
this.applicationMappingDAO = DeviceManagementDAOFactory.getApplicationMappingDAO();
|
|
|
@ -102,24 +96,105 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void updateApplicationStatus(DeviceIdentifier deviceId, Application application,
|
|
|
|
public void updateApplicationStatus(DeviceIdentifier deviceId, Application application,
|
|
|
|
String status) throws ApplicationManagementException {
|
|
|
|
String status) throws ApplicationManagementException {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public String getApplicationStatus(DeviceIdentifier deviceId,
|
|
|
|
public String getApplicationStatus(DeviceIdentifier deviceId,
|
|
|
|
Application application) throws ApplicationManagementException {
|
|
|
|
Application application) throws ApplicationManagementException {
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void installApplication(Operation operation, List<DeviceIdentifier> deviceIds)
|
|
|
|
public void installApplicationForDevices(Operation operation, List<DeviceIdentifier> deviceIds)
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
|
|
|
|
|
|
|
|
for (DeviceIdentifier deviceId : deviceIds) {
|
|
|
|
try {
|
|
|
|
DeviceManagementService dms =
|
|
|
|
DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().addOperation(operation, deviceIds);
|
|
|
|
this.getPluginRepository().getDeviceManagementService(deviceId.getType());
|
|
|
|
} catch (OperationManagementException opeEx) {
|
|
|
|
dms.installApplication(operation, deviceIds);
|
|
|
|
String errorMsg = "Error in add operation at app installation:" + opeEx.getErrorMessage();
|
|
|
|
|
|
|
|
log.error(errorMsg, opeEx);
|
|
|
|
|
|
|
|
throw new ApplicationManagementException(errorMsg, opeEx);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void installApplicationForUsers(Operation operation, List<String> userNameList)
|
|
|
|
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String userName = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
List<Device> deviceList;
|
|
|
|
|
|
|
|
List<DeviceIdentifier> deviceIdentifierList = new ArrayList<>();
|
|
|
|
|
|
|
|
DeviceIdentifier deviceIdentifier;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (String user : userNameList) {
|
|
|
|
|
|
|
|
userName = user;
|
|
|
|
|
|
|
|
deviceList = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDevicesOfUser
|
|
|
|
|
|
|
|
(user);
|
|
|
|
|
|
|
|
for (Device device : deviceList) {
|
|
|
|
|
|
|
|
deviceIdentifier = new DeviceIdentifier();
|
|
|
|
|
|
|
|
deviceIdentifier.setId(Integer.toString(device.getId()));
|
|
|
|
|
|
|
|
deviceIdentifier.setType(device.getType());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
deviceIdentifierList.add(deviceIdentifier);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DeviceManagementDataHolder.getInstance().getDeviceManagementProvider()
|
|
|
|
|
|
|
|
.addOperation(operation, deviceIdentifierList);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (DeviceManagementException devEx) {
|
|
|
|
|
|
|
|
String errorMsg = "Error in get devices for user: "+userName+ " in app installation:" + devEx.getErrorMessage();
|
|
|
|
|
|
|
|
log.error(errorMsg, devEx);
|
|
|
|
|
|
|
|
throw new ApplicationManagementException(errorMsg, devEx);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (OperationManagementException opeEx) {
|
|
|
|
|
|
|
|
String errorMsg = "Error in add operation at app installation:" + opeEx.getErrorMessage();
|
|
|
|
|
|
|
|
log.error(errorMsg, opeEx);
|
|
|
|
|
|
|
|
throw new ApplicationManagementException(errorMsg, opeEx);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void installApplicationForUserRoles(Operation operation, List<String> userRoleList)
|
|
|
|
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String userRole = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
List<Device> deviceList;
|
|
|
|
|
|
|
|
List<DeviceIdentifier> deviceIdentifierList = new ArrayList<>();
|
|
|
|
|
|
|
|
DeviceIdentifier deviceIdentifier;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (String role : userRoleList) {
|
|
|
|
|
|
|
|
userRole = role;
|
|
|
|
|
|
|
|
deviceList = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider()
|
|
|
|
|
|
|
|
.getAllDevicesOfRole(userRole);
|
|
|
|
|
|
|
|
for (Device device : deviceList) {
|
|
|
|
|
|
|
|
deviceIdentifier = new DeviceIdentifier();
|
|
|
|
|
|
|
|
deviceIdentifier.setId(Integer.toString(device.getId()));
|
|
|
|
|
|
|
|
deviceIdentifier.setType(device.getType());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
deviceIdentifierList.add(deviceIdentifier);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DeviceManagementDataHolder.getInstance().getDeviceManagementProvider()
|
|
|
|
|
|
|
|
.addOperation(operation, deviceIdentifierList);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (DeviceManagementException devEx) {
|
|
|
|
|
|
|
|
String errorMsg = "Error in get devices for user role "+userRole+ " in app installation:"
|
|
|
|
|
|
|
|
+ devEx.getErrorMessage();
|
|
|
|
|
|
|
|
log.error(errorMsg, devEx);
|
|
|
|
|
|
|
|
throw new ApplicationManagementException(errorMsg, devEx);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (OperationManagementException opeEx) {
|
|
|
|
|
|
|
|
String errorMsg = "Error in add operation at app installation:" + opeEx.getErrorMessage();
|
|
|
|
|
|
|
|
log.error(errorMsg, opeEx);
|
|
|
|
|
|
|
|
throw new ApplicationManagementException(errorMsg, opeEx);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -167,10 +242,6 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DeviceManagementPluginRepository getPluginRepository() {
|
|
|
|
|
|
|
|
return pluginRepository;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void updateApplicationListInstalledInDevice(
|
|
|
|
public void updateApplicationListInstalledInDevice(
|
|
|
|
DeviceIdentifier deviceIdentifier, List<Application> applications) throws ApplicationManagementException {
|
|
|
|
DeviceIdentifier deviceIdentifier, List<Application> applications) throws ApplicationManagementException {
|
|
|
@ -256,24 +327,4 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void registerDeviceManagementService(DeviceManagementService deviceManagementService) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
pluginRepository.addDeviceManagementProvider(deviceManagementService);
|
|
|
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
log.error("Error occurred while registering device management plugin '" +
|
|
|
|
|
|
|
|
deviceManagementService.getType() + "'", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void unregisterDeviceManagementService(DeviceManagementService deviceManagementService) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
pluginRepository.removeDeviceManagementProvider(deviceManagementService);
|
|
|
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
log.error("Error occurred while un-registering device management plugin '" +
|
|
|
|
|
|
|
|
deviceManagementService.getType() + "'", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|