|
|
@ -18,12 +18,9 @@
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
package org.wso2.carbon.device.mgt.mobile.impl.windows;
|
|
|
|
package org.wso2.carbon.device.mgt.mobile.impl.windows;
|
|
|
|
|
|
|
|
|
|
|
|
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.DeviceManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.Feature;
|
|
|
|
import org.wso2.carbon.device.mgt.common.Feature;
|
|
|
|
import org.wso2.carbon.device.mgt.common.FeatureManager;
|
|
|
|
import org.wso2.carbon.device.mgt.common.FeatureManager;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.dao.AbstractMobileDeviceManagementDAOFactory;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileFeatureDAO;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileFeatureDAO;
|
|
|
@ -37,7 +34,6 @@ import java.util.List;
|
|
|
|
public class WindowsFeatureManager implements FeatureManager {
|
|
|
|
public class WindowsFeatureManager implements FeatureManager {
|
|
|
|
|
|
|
|
|
|
|
|
private MobileFeatureDAO featureDAO;
|
|
|
|
private MobileFeatureDAO featureDAO;
|
|
|
|
private static final Log log = LogFactory.getLog(WindowsFeatureManager.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public WindowsFeatureManager() {
|
|
|
|
public WindowsFeatureManager() {
|
|
|
|
MobileDeviceManagementDAOFactory daoFactory = new WindowsDAOFactory();
|
|
|
|
MobileDeviceManagementDAOFactory daoFactory = new WindowsDAOFactory();
|
|
|
@ -47,27 +43,39 @@ public class WindowsFeatureManager implements FeatureManager {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean addFeature(Feature feature) throws DeviceManagementException {
|
|
|
|
public boolean addFeature(Feature feature) throws DeviceManagementException {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
WindowsDAOFactory.beginTransaction();
|
|
|
|
WindowsDAOFactory.beginTransaction();
|
|
|
|
MobileFeature mobileFeature = MobileDeviceManagementUtil.convertToMobileFeature(feature);
|
|
|
|
MobileFeature mobileFeature = MobileDeviceManagementUtil.convertToMobileFeature(feature);
|
|
|
|
featureDAO.addFeature(mobileFeature);
|
|
|
|
featureDAO.addFeature(mobileFeature);
|
|
|
|
WindowsDAOFactory.commitTransaction();
|
|
|
|
WindowsDAOFactory.commitTransaction();
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
WindowsDAOFactory.rollbackTransaction();
|
|
|
|
WindowsDAOFactory.rollbackTransaction();
|
|
|
|
throw new DeviceManagementException("Error occurred while adding the feature", e);
|
|
|
|
throw new DeviceManagementException("Error occurred while adding the feature", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean addFeatures(List<Feature> list) throws DeviceManagementException {
|
|
|
|
public boolean addFeatures(List<Feature> features) throws DeviceManagementException {
|
|
|
|
return false;
|
|
|
|
List<MobileFeature> mobileFeatures = new ArrayList<MobileFeature>();
|
|
|
|
|
|
|
|
for (Feature feature : features) {
|
|
|
|
|
|
|
|
mobileFeatures.add(MobileDeviceManagementUtil.convertToMobileFeature(feature));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
WindowsDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
featureDAO.addFeatures(mobileFeatures);
|
|
|
|
|
|
|
|
WindowsDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
WindowsDAOFactory.rollbackTransaction();
|
|
|
|
|
|
|
|
throw new DeviceManagementException("Error occurred while adding the features", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Feature getFeature(String name) throws DeviceManagementException {
|
|
|
|
public Feature getFeature(String name) throws DeviceManagementException {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
MobileFeature mobileFeature = featureDAO.getFeatureByCode(name);
|
|
|
|
MobileFeature mobileFeature = featureDAO.getFeatureByCode(name);
|
|
|
|
Feature feature = MobileDeviceManagementUtil.convertToFeature(mobileFeature);
|
|
|
|
Feature feature = MobileDeviceManagementUtil.convertToFeature(mobileFeature);
|
|
|
|
return feature;
|
|
|
|
return feature;
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
throw new DeviceManagementException("Error occurred while retrieving the feature", e);
|
|
|
|
throw new DeviceManagementException("Error occurred while retrieving the feature", e);
|
|
|
@ -86,7 +94,7 @@ public class WindowsFeatureManager implements FeatureManager {
|
|
|
|
return featureList;
|
|
|
|
return featureList;
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
throw new DeviceManagementException("Error occurred while retrieving the list of features registered for " +
|
|
|
|
throw new DeviceManagementException("Error occurred while retrieving the list of features registered for " +
|
|
|
|
"Android platform", e);
|
|
|
|
"Windows platform", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -94,12 +102,12 @@ public class WindowsFeatureManager implements FeatureManager {
|
|
|
|
public boolean removeFeature(String code) throws DeviceManagementException {
|
|
|
|
public boolean removeFeature(String code) throws DeviceManagementException {
|
|
|
|
boolean status;
|
|
|
|
boolean status;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
WindowsDAOFactory.beginTransaction();
|
|
|
|
WindowsDAOFactory.beginTransaction();
|
|
|
|
featureDAO.deleteFeatureByCode(code);
|
|
|
|
featureDAO.deleteFeatureByCode(code);
|
|
|
|
WindowsDAOFactory.commitTransaction();
|
|
|
|
WindowsDAOFactory.commitTransaction();
|
|
|
|
status = true;
|
|
|
|
status = true;
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
WindowsDAOFactory.rollbackTransaction();
|
|
|
|
WindowsDAOFactory.rollbackTransaction();
|
|
|
|
throw new DeviceManagementException("Error occurred while removing the feature", e);
|
|
|
|
throw new DeviceManagementException("Error occurred while removing the feature", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
return status;
|
|
|
@ -107,7 +115,64 @@ public class WindowsFeatureManager implements FeatureManager {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean addSupportedFeaturesToDB() throws DeviceManagementException {
|
|
|
|
public boolean addSupportedFeaturesToDB() throws DeviceManagementException {
|
|
|
|
return false;
|
|
|
|
synchronized (this) {
|
|
|
|
|
|
|
|
List<Feature> supportedFeatures = getSupportedFeatures();
|
|
|
|
|
|
|
|
List<Feature> existingFeatures = this.getFeatures();
|
|
|
|
|
|
|
|
List<Feature> missingFeatures = MobileDeviceManagementUtil.
|
|
|
|
|
|
|
|
getMissingFeatures(supportedFeatures, existingFeatures);
|
|
|
|
|
|
|
|
if (missingFeatures.size() > 0) {
|
|
|
|
|
|
|
|
return this.addFeatures(missingFeatures);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static List<Feature> getSupportedFeatures() {
|
|
|
|
|
|
|
|
List<Feature> supportedFeatures = new ArrayList<Feature>();
|
|
|
|
|
|
|
|
Feature feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("DEVICE_LOCK");
|
|
|
|
|
|
|
|
feature.setName("Device Lock");
|
|
|
|
|
|
|
|
feature.setDescription("Lock the device");
|
|
|
|
|
|
|
|
supportedFeatures.add(feature);
|
|
|
|
|
|
|
|
feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("CAMERA");
|
|
|
|
|
|
|
|
feature.setName("camera");
|
|
|
|
|
|
|
|
feature.setDescription("Enable or disable camera");
|
|
|
|
|
|
|
|
supportedFeatures.add(feature);
|
|
|
|
|
|
|
|
feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("DEVICE_INFO");
|
|
|
|
|
|
|
|
feature.setName("Device info");
|
|
|
|
|
|
|
|
feature.setDescription("Request device information");
|
|
|
|
|
|
|
|
supportedFeatures.add(feature);
|
|
|
|
|
|
|
|
feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("WIPE_DATA");
|
|
|
|
|
|
|
|
feature.setName("Wipe Data");
|
|
|
|
|
|
|
|
feature.setDescription("Factory reset the device");
|
|
|
|
|
|
|
|
supportedFeatures.add(feature);
|
|
|
|
|
|
|
|
feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("ENCRYPT_STORAGE");
|
|
|
|
|
|
|
|
feature.setName("Encrypt storage");
|
|
|
|
|
|
|
|
feature.setDescription("Encrypt storage");
|
|
|
|
|
|
|
|
supportedFeatures.add(feature);
|
|
|
|
|
|
|
|
feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("DEVICE_RING");
|
|
|
|
|
|
|
|
feature.setName("Ring");
|
|
|
|
|
|
|
|
feature.setDescription("Ring the device");
|
|
|
|
|
|
|
|
supportedFeatures.add(feature);
|
|
|
|
|
|
|
|
feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("PASSCODE_POLICY");
|
|
|
|
|
|
|
|
feature.setName("Password Policy");
|
|
|
|
|
|
|
|
feature.setDescription("Set passcode policy");
|
|
|
|
|
|
|
|
supportedFeatures.add(feature);
|
|
|
|
|
|
|
|
feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("DISENROLL");
|
|
|
|
|
|
|
|
feature.setName("DisEnroll");
|
|
|
|
|
|
|
|
feature.setDescription("DisEnroll the device");
|
|
|
|
|
|
|
|
supportedFeatures.add(feature);
|
|
|
|
|
|
|
|
feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("LOCK_RESET");
|
|
|
|
|
|
|
|
feature.setName("LockReset");
|
|
|
|
|
|
|
|
feature.setDescription("Lock Reset device");
|
|
|
|
|
|
|
|
return supportedFeatures;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|