Merge branch 'hasuniea-master'

revert-dabc3590
harshanl 9 years ago
commit 1f06ad4d18

@ -32,6 +32,7 @@ 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.dto.MobileDevice; import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice;
import org.wso2.carbon.device.mgt.mobile.impl.windows.dao.WindowsDAOFactory; import org.wso2.carbon.device.mgt.mobile.impl.windows.dao.WindowsDAOFactory;
import org.wso2.carbon.device.mgt.mobile.impl.windows.util.WindowsPluginUtils;
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil; import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
import org.wso2.carbon.registry.api.RegistryException; import org.wso2.carbon.registry.api.RegistryException;
import org.wso2.carbon.registry.api.Resource; import org.wso2.carbon.registry.api.Resource;
@ -56,6 +57,12 @@ public class WindowsDeviceManager implements DeviceManager {
public WindowsDeviceManager() { public WindowsDeviceManager() {
this.daoFactory = new WindowsDAOFactory(); this.daoFactory = new WindowsDAOFactory();
this.licenseManager = new RegistryBasedLicenseManager(); this.licenseManager = new RegistryBasedLicenseManager();
License defaultLicense = WindowsPluginUtils.getDefaultLicense();
try {
licenseManager.addLicense(WindowsDeviceManagementService.DEVICE_TYPE_WINDOWS, defaultLicense);
} catch (LicenseManagementException e) {
log.error("Error occurred while adding default license for Windows devices", e);
}
} }
@Override @Override
@ -66,7 +73,7 @@ public class WindowsDeviceManager implements DeviceManager {
@Override @Override
public boolean saveConfiguration(TenantConfiguration tenantConfiguration) public boolean saveConfiguration(TenantConfiguration tenantConfiguration)
throws DeviceManagementException { throws DeviceManagementException {
boolean status = false; boolean status;
Resource resource; Resource resource;
try { try {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
@ -243,7 +250,7 @@ public class WindowsDeviceManager implements DeviceManager {
@Override @Override
public License getLicense(String languageCode) throws LicenseManagementException { public License getLicense(String languageCode) throws LicenseManagementException {
return licenseManager.getLicense(WindowsDeviceManagementService.DEVICE_TYPE_WINDOWS, languageCode); return licenseManager.getLicense(WindowsDeviceManagementService.DEVICE_TYPE_WINDOWS, languageCode);
} }
@Override @Override

@ -18,26 +18,52 @@
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.Device; import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
import org.wso2.carbon.policy.mgt.common.Policy; import org.wso2.carbon.policy.mgt.common.Policy;
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData;
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature;
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException;
import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService; import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class WindowsPolicyMonitoringService implements PolicyMonitoringService { public class WindowsPolicyMonitoringService implements PolicyMonitoringService {
private static Log log = LogFactory.getLog(WindowsPolicyMonitoringService.class);
@Override @Override
public void notifyDevices(List<Device> list) throws PolicyComplianceException { public void notifyDevices(List<Device> list) throws PolicyComplianceException {
} }
@Override @Override
public ComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy, Object o) throws PolicyComplianceException { public ComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy, Object compliancePayload)
return null; throws PolicyComplianceException {
if (log.isDebugEnabled()) {
log.debug("checking policy compliance status of device '" + deviceIdentifier.getId() + "'");
}
List<ComplianceFeature> complianceFeatures = (List<ComplianceFeature>) compliancePayload;
List<ComplianceFeature> nonComplianceFeatures = new ArrayList<>();
ComplianceData complianceData = new ComplianceData();
if (policy == null || compliancePayload == null) {
return complianceData;
}
for (ComplianceFeature complianceFeature : complianceFeatures) {
if (!complianceFeature.isCompliant()) {
complianceData.setStatus(false);
nonComplianceFeatures.add(complianceFeature);
break;
}
}
complianceData.setComplianceFeatures(nonComplianceFeatures);
return complianceData;
} }
@Override @Override

@ -117,8 +117,6 @@ public class WindowsDAOFactory extends MobileDeviceManagementDAOFactory
} }
} catch (SQLException e) { } catch (SQLException e) {
log.error("Error occurred while committing the transaction", e); log.error("Error occurred while committing the transaction", e);
} finally {
closeConnection();
} }
} }
@ -145,8 +143,6 @@ public class WindowsDAOFactory extends MobileDeviceManagementDAOFactory
} }
} catch (SQLException e) { } catch (SQLException e) {
log.warn("Error occurred while roll-backing the transaction", e); log.warn("Error occurred while roll-backing the transaction", e);
} finally {
closeConnection();
} }
} }
} }

@ -53,7 +53,8 @@ public class WindowsDeviceDAOImpl implements MobileDeviceDAO {
conn = WindowsDAOFactory.getConnection(); conn = WindowsDAOFactory.getConnection();
String selectDBQuery = String selectDBQuery =
"SELECT MOBILE_DEVICE_ID, CHANNEL_URI, DEVICE_INFO, IMEI, IMSI, " + "SELECT MOBILE_DEVICE_ID, CHANNEL_URI, DEVICE_INFO, IMEI, IMSI, " +
"OS_VERSION, DEVICE_MODEL, VENDOR, LATITUDE, LONGITUDE, SERIAL, MAC_ADDRESS, OS_VERSION, DEVICE_NAME " + "OS_VERSION, DEVICE_MODEL, VENDOR, LATITUDE, LONGITUDE, SERIAL, MAC_ADDRESS," +
" OS_VERSION, DEVICE_NAME " +
"FROM WINDOWS_DEVICE WHERE MOBILE_DEVICE_ID = ?"; "FROM WINDOWS_DEVICE WHERE MOBILE_DEVICE_ID = ?";
stmt = conn.prepareStatement(selectDBQuery); stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, mblDeviceId); stmt.setString(1, mblDeviceId);
@ -62,17 +63,21 @@ public class WindowsDeviceDAOImpl implements MobileDeviceDAO {
while (rs.next()) { while (rs.next()) {
mobileDevice = new MobileDevice(); mobileDevice = new MobileDevice();
mobileDevice.setMobileDeviceId(rs.getString(WindowsPluginConstants.MOBILE_DEVICE_ID)); mobileDevice.setMobileDeviceId(rs.getString(WindowsPluginConstants.MOBILE_DEVICE_ID));
mobileDevice.setVendor(rs.getString(WindowsPluginConstants.IMEI)); mobileDevice.setImei(rs.getString(WindowsPluginConstants.IMEI));
mobileDevice.setLatitude(rs.getString(WindowsPluginConstants.IMSI)); mobileDevice.setImsi(rs.getString(WindowsPluginConstants.IMSI));
mobileDevice.setLongitude(rs.getString(WindowsPluginConstants.OS_VERSION)); mobileDevice.setModel(rs.getString(WindowsPluginConstants.DEVICE_MODEL));
mobileDevice.setImei(rs.getString(WindowsPluginConstants.DEVICE_MODEL)); mobileDevice.setVendor(rs.getString(WindowsPluginConstants.VENDOR));
mobileDevice.setImsi(rs.getString(WindowsPluginConstants.VENDOR)); mobileDevice.setLatitude(rs.getString(WindowsPluginConstants.LATITUDE));
mobileDevice.setLongitude(rs.getString(WindowsPluginConstants.LONGITUDE));
mobileDevice.setSerial(rs.getString(WindowsPluginConstants.SERIAL));
mobileDevice.setOsVersion(rs.getString(WindowsPluginConstants.LATITUDE)); mobileDevice.setOsVersion(rs.getString(WindowsPluginConstants.LATITUDE));
Map<String, String> propertyMap = new HashMap<String, String>(); Map<String, String> propertyMap = new HashMap<String, String>();
propertyMap.put(WindowsPluginConstants.CHANNEL_URI, rs.getString(WindowsPluginConstants.CHANNEL_URI)); propertyMap.put(WindowsPluginConstants.CHANNEL_URI, rs.getString(WindowsPluginConstants.CHANNEL_URI));
propertyMap.put(WindowsPluginConstants.DEVICE_INFO, rs.getString(WindowsPluginConstants.DEVICE_INFO)); propertyMap.put(WindowsPluginConstants.DEVICE_INFO, rs.getString(WindowsPluginConstants.DEVICE_INFO));
propertyMap.put(WindowsPluginConstants.MAC_ADDRESS, rs.getString(WindowsPluginConstants.MAC_ADDRESS));
propertyMap.put(WindowsPluginConstants.DEVICE_NAME, rs.getString(WindowsPluginConstants.DEVICE_NAME)); propertyMap.put(WindowsPluginConstants.DEVICE_NAME, rs.getString(WindowsPluginConstants.DEVICE_NAME));
mobileDevice.setDeviceProperties(propertyMap); mobileDevice.setDeviceProperties(propertyMap);
} }
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
@ -214,7 +219,8 @@ public class WindowsDeviceDAOImpl implements MobileDeviceDAO {
conn = WindowsDAOFactory.getConnection(); conn = WindowsDAOFactory.getConnection();
String selectDBQuery = String selectDBQuery =
"SELECT MOBILE_DEVICE_ID, CHANNEL_URI, DEVICE_INFO, IMEI, IMSI, " + "SELECT MOBILE_DEVICE_ID, CHANNEL_URI, DEVICE_INFO, IMEI, IMSI, " +
"OS_VERSION, DEVICE_MODEL, VENDOR, LATITUDE, LONGITUDE, SERIAL, MAC_ADDRESS, OS_VERSION, DEVICE_NAME " + "OS_VERSION, DEVICE_MODEL, VENDOR, LATITUDE, LONGITUDE, SERIAL, MAC_ADDRESS," +
" OS_VERSION, DEVICE_NAME " +
"FROM WINDOWS_DEVICE"; "FROM WINDOWS_DEVICE";
stmt = conn.prepareStatement(selectDBQuery); stmt = conn.prepareStatement(selectDBQuery);
rs = stmt.executeQuery(); rs = stmt.executeQuery();

@ -25,7 +25,7 @@ public class WindowsPluginConstants {
//properties related to database table WINDOWS_DEVICE //properties related to database table WINDOWS_DEVICE
public static final String MOBILE_DEVICE_ID = "MOBILE_DEVICE_ID"; public static final String MOBILE_DEVICE_ID = "MOBILE_DEVICE_ID";
public static final String CHANNEL_URI = "CHANNEL_URI "; public static final String CHANNEL_URI = "CHANNEL_URI";
public static final String DEVICE_INFO = "DEVICE_INFO"; public static final String DEVICE_INFO = "DEVICE_INFO";
public static final String IMEI = "IMEI"; public static final String IMEI = "IMEI";
public static final String IMSI = "IMSI"; public static final String IMSI = "IMSI";

@ -0,0 +1,58 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* /
*/
package org.wso2.carbon.device.mgt.mobile.impl.windows.util;
import org.wso2.carbon.device.mgt.common.license.mgt.License;
import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManagementService;
/**
* Contains utility method used by Windows plugin.
*/
public class WindowsPluginUtils {
public static License getDefaultLicense() {
License license = new License();
license.setName(WindowsDeviceManagementService.DEVICE_TYPE_WINDOWS);
license.setLanguage("en_US");
license.setVersion("1.0.0");
license.setText("This End User License Agreement (“Agreement”) is a legal agreement between you (“You”) " +
"and WSO2, Inc., regarding the enrollment of Your personal mobile device (“Device”) in SoRs " +
"mobile device management program, and the loading to and removal from Your Device and Your use " +
"of certain applications and any associated software and user documentation, whether provided in " +
"“online” or electronic format, used in connection with the operation of or provision of services " +
"to WSO2, Inc., BY SELECTING “I ACCEPT” DURING INSTALLATION, YOU ARE ENROLLING YOUR DEVICE, AND " +
"THEREBY AUTHORIZING SOR OR ITS AGENTS TO INSTALL, UPDATE AND REMOVE THE APPS FROM YOUR DEVICE AS " +
"DESCRIBED IN THIS AGREEMENT. YOU ARE ALSO EXPLICITLY ACKNOWLEDGING AND AGREEING THAT (1) THIS IS " +
"A BINDING CONTRACT AND (2) YOU HAVE READ AND AGREE TO THE TERMS OF THIS AGREEMENT.\n" +
"\n" +
"IF YOU DO NOT ACCEPT THESE TERMS, DO NOT ENROLL YOUR DEVICE AND DO NOT PROCEED ANY FURTHER.\n" +
"\n" +
"You agree that: (1) You understand and agree to be bound by the terms and conditions contained " +
"in this Agreement, and (2) You are at least 21 years old and have the legal capacity to enter " +
"into this Agreement as defined by the laws of Your jurisdiction. SoR shall have the right, " +
"without prior notice, to terminate or suspend (i) this Agreement, (ii) the enrollment of Your " +
"Device, or (iii) the functioning of the Apps in the event of a violation of this Agreement or " +
"the cessation of Your relationship with SoR (including termination of Your employment if You are " +
"an employee or expiration or termination of Your applicable franchise or supply agreement if You " +
"are a franchisee of or supplier to the WSO2 WSO2, Inc., system). SoR expressly reserves all " +
"rights not expressly granted herein.");
return license;
}
}
Loading…
Cancel
Save