mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge branch 'master' of https://github.com/geethkokila/product-cdm
This commit is contained in:
commit
6eabb80e47
@ -28,12 +28,11 @@ public class MobileDataSourceConfig {
|
|||||||
private JNDILookupDefinition jndiLookupDefinition;
|
private JNDILookupDefinition jndiLookupDefinition;
|
||||||
|
|
||||||
@XmlElement(name = "JndiLookupDefinition", nillable = true)
|
@XmlElement(name = "JndiLookupDefinition", nillable = true)
|
||||||
public JNDILookupDefinition getJndiLookupDefintion() {
|
public JNDILookupDefinition getJndiLookupDefinition() {
|
||||||
return jndiLookupDefinition;
|
return jndiLookupDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setJndiLookupDefinition(JNDILookupDefinition jndiLookupDefinition) {
|
public void setJndiLookupDefinition(JNDILookupDefinition jndiLookupDefinition) {
|
||||||
this.jndiLookupDefinition = jndiLookupDefinition;
|
this.jndiLookupDefinition = jndiLookupDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,81 +19,108 @@ package org.wso2.carbon.device.mgt.mobile.dao;
|
|||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
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.mobile.DataSourceListener;
|
import org.wso2.carbon.device.mgt.mobile.config.datasource.JNDILookupDefinition;
|
||||||
import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig;
|
import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig;
|
||||||
import org.wso2.carbon.device.mgt.mobile.dao.impl.*;
|
import org.wso2.carbon.device.mgt.mobile.dao.impl.*;
|
||||||
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
|
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
|
||||||
import org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementBundleActivator;
|
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory class used to create MobileDeviceManagement related DAO objects.
|
* Factory class used to create MobileDeviceManagement related DAO objects.
|
||||||
*/
|
*/
|
||||||
public class MobileDeviceManagementDAOFactory implements DataSourceListener {
|
public class MobileDeviceManagementDAOFactory {
|
||||||
|
|
||||||
private static DataSource dataSource;
|
private static DataSource dataSource;
|
||||||
private static MobileDataSourceConfig mobileDataSourceConfig;
|
private static MobileDataSourceConfig mobileDataSourceConfig;
|
||||||
private static final Log log = LogFactory.getLog(MobileDeviceManagementDAOFactory.class);
|
private static final Log log = LogFactory.getLog(MobileDeviceManagementDAOFactory.class);
|
||||||
|
|
||||||
public MobileDeviceManagementDAOFactory() {
|
public MobileDeviceManagementDAOFactory() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() throws DeviceManagementException {
|
public static void init() {
|
||||||
dataSource = MobileDeviceManagementDAOUtil.resolveDataSource(mobileDataSourceConfig);
|
try {
|
||||||
if (dataSource != null) {
|
dataSource = MobileDeviceManagementDAOFactory.resolveDataSource(mobileDataSourceConfig);
|
||||||
MobileDeviceManagementDAOUtil.createDataSource(dataSource);
|
} catch (DeviceManagementException e) {
|
||||||
} else {
|
log.error("Exception occurred while initializing the mobile datasource.",e);
|
||||||
MobileDeviceManagementBundleActivator.registerDataSourceListener(this);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static MobileDeviceDAO getMobileDeviceDAO() {
|
/**
|
||||||
return new MobileDeviceDAOImpl(dataSource);
|
* Resolve data source from the data source definition.
|
||||||
}
|
*
|
||||||
|
* @param config Mobile data source configuration
|
||||||
|
* @return data source resolved from the data source definition
|
||||||
|
*/
|
||||||
|
private static DataSource resolveDataSource(MobileDataSourceConfig config)
|
||||||
|
throws DeviceManagementException {
|
||||||
|
DataSource dataSource = null;
|
||||||
|
if (config == null) {
|
||||||
|
throw new RuntimeException("Device Management Repository data source configuration " +
|
||||||
|
"is null and thus, is not initialized");
|
||||||
|
}
|
||||||
|
JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition();
|
||||||
|
if (jndiConfig != null) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Initializing Device Management Repository data source using the JNDI " +
|
||||||
|
"Lookup Definition");
|
||||||
|
}
|
||||||
|
List<JNDILookupDefinition.JNDIProperty> jndiPropertyList =
|
||||||
|
jndiConfig.getJndiProperties();
|
||||||
|
if (jndiPropertyList != null) {
|
||||||
|
Hashtable<Object, Object> jndiProperties = new Hashtable<Object, Object>();
|
||||||
|
for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) {
|
||||||
|
jndiProperties.put(prop.getName(), prop.getValue());
|
||||||
|
}
|
||||||
|
dataSource =
|
||||||
|
MobileDeviceManagementDAOUtil
|
||||||
|
.lookupDataSource(jndiConfig.getJndiName(), jndiProperties);
|
||||||
|
} else {
|
||||||
|
dataSource = MobileDeviceManagementDAOUtil
|
||||||
|
.lookupDataSource(jndiConfig.getJndiName(), null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dataSource;
|
||||||
|
}
|
||||||
|
|
||||||
public static MobileOperationDAO getMobileOperationDAO() {
|
public static MobileDeviceDAO getMobileDeviceDAO() {
|
||||||
return new MobileOperationDAOImpl(dataSource);
|
return new MobileDeviceDAOImpl(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MobileOperationPropertyDAO getMobileOperationPropertyDAO() {
|
public static MobileOperationDAO getMobileOperationDAO() {
|
||||||
return new MobileOperationPropertyDAOImpl(dataSource);
|
return new MobileOperationDAOImpl(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MobileDeviceOperationDAO getMobileDeviceOperationDAO() {
|
public static MobileOperationPropertyDAO getMobileOperationPropertyDAO() {
|
||||||
return new MobileDeviceOperationDAOImpl(dataSource);
|
return new MobileOperationPropertyDAOImpl(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FeatureDAO getFeatureDAO() {
|
public static MobileDeviceOperationDAO getMobileDeviceOperationDAO() {
|
||||||
return new FeatureDAOImpl(dataSource);
|
return new MobileDeviceOperationDAOImpl(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FeaturePropertyDAO getFeaturePropertyDAO() {
|
public static FeatureDAO getFeatureDAO() {
|
||||||
return new FeaturePropertyDAOImpl(dataSource);
|
return new FeatureDAOImpl(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MobileDataSourceConfig getMobileDeviceManagementConfig() {
|
public static FeaturePropertyDAO getFeaturePropertyDAO() {
|
||||||
return mobileDataSourceConfig;
|
return new FeaturePropertyDAOImpl(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setMobileDataSourceConfig(
|
public static MobileDataSourceConfig getMobileDeviceManagementConfig() {
|
||||||
MobileDataSourceConfig mobileDataSourceConfig) {
|
return mobileDataSourceConfig;
|
||||||
MobileDeviceManagementDAOFactory.mobileDataSourceConfig =
|
}
|
||||||
mobileDataSourceConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DataSource getDataSource() {
|
public static void setMobileDataSourceConfig(
|
||||||
return dataSource;
|
MobileDataSourceConfig mobileDataSourceConfig) {
|
||||||
}
|
MobileDeviceManagementDAOFactory.mobileDataSourceConfig =
|
||||||
|
mobileDataSourceConfig;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public static DataSource getDataSource() {
|
||||||
public void notifyObserver() {
|
return dataSource;
|
||||||
try {
|
}
|
||||||
dataSource = MobileDeviceManagementDAOUtil.resolveDataSource(mobileDataSourceConfig);
|
}
|
||||||
MobileDeviceManagementDAOUtil.createDataSource(dataSource);
|
|
||||||
} catch (DeviceManagementException e) {
|
|
||||||
log.error("Error occurred while resolving mobile device management metadata repository data source", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -52,7 +52,7 @@ public class MobileDeviceOperationDAOImpl implements MobileDeviceOperationDAO {
|
|||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
String createDBQuery =
|
String createDBQuery =
|
||||||
"INSERT INTO MBL_DEVICE_OPERATION(DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE) VALUES (?, ?, ?, ?)";
|
"INSERT INTO MBL_DEVICE_OPERATION_MAPPING (DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE) VALUES (?, ?, ?, ?)";
|
||||||
|
|
||||||
stmt = conn.prepareStatement(createDBQuery);
|
stmt = conn.prepareStatement(createDBQuery);
|
||||||
stmt.setString(1, deviceOperation.getDeviceId());
|
stmt.setString(1, deviceOperation.getDeviceId());
|
||||||
@ -86,7 +86,7 @@ public class MobileDeviceOperationDAOImpl implements MobileDeviceOperationDAO {
|
|||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
String updateDBQuery =
|
String updateDBQuery =
|
||||||
"UPDATE MBL_DEVICE_OPERATION SET SENT_DATE = ?, RECEIVED_DATE = ? WHERE DEVICE_ID = ? AND OPERATION_ID=?";
|
"UPDATE MBL_DEVICE_OPERATION_MAPPING SET SENT_DATE = ?, RECEIVED_DATE = ? WHERE DEVICE_ID = ? AND OPERATION_ID=?";
|
||||||
stmt = conn.prepareStatement(updateDBQuery);
|
stmt = conn.prepareStatement(updateDBQuery);
|
||||||
stmt.setLong(1, deviceOperation.getSentDate());
|
stmt.setLong(1, deviceOperation.getSentDate());
|
||||||
stmt.setLong(2, deviceOperation.getReceivedDate());
|
stmt.setLong(2, deviceOperation.getReceivedDate());
|
||||||
@ -117,7 +117,7 @@ public class MobileDeviceOperationDAOImpl implements MobileDeviceOperationDAO {
|
|||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
String deleteDBQuery =
|
String deleteDBQuery =
|
||||||
"DELETE FROM MBL_DEVICE_OPERATION WHERE DEVICE_ID = ? AND OPERATION_ID=?";
|
"DELETE FROM MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID=?";
|
||||||
stmt = conn.prepareStatement(deleteDBQuery);
|
stmt = conn.prepareStatement(deleteDBQuery);
|
||||||
stmt.setString(1, deviceId);
|
stmt.setString(1, deviceId);
|
||||||
stmt.setInt(2, operationId);
|
stmt.setInt(2, operationId);
|
||||||
@ -146,7 +146,7 @@ public class MobileDeviceOperationDAOImpl implements MobileDeviceOperationDAO {
|
|||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
String selectDBQuery =
|
String selectDBQuery =
|
||||||
"SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE FROM MBL_DEVICE_OPERATION WHERE DEVICE_ID = ? AND OPERATION_ID=?";
|
"SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE FROM MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID=?";
|
||||||
stmt = conn.prepareStatement(selectDBQuery);
|
stmt = conn.prepareStatement(selectDBQuery);
|
||||||
stmt.setString(1, deviceId);
|
stmt.setString(1, deviceId);
|
||||||
stmt.setInt(2, operationId);
|
stmt.setInt(2, operationId);
|
||||||
@ -181,7 +181,7 @@ public class MobileDeviceOperationDAOImpl implements MobileDeviceOperationDAO {
|
|||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
String selectDBQuery =
|
String selectDBQuery =
|
||||||
"SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE FROM MBL_DEVICE_OPERATION WHERE DEVICE_ID = ?";
|
"SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE FROM MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ?";
|
||||||
stmt = conn.prepareStatement(selectDBQuery);
|
stmt = conn.prepareStatement(selectDBQuery);
|
||||||
stmt.setString(1, deviceId);
|
stmt.setString(1, deviceId);
|
||||||
ResultSet resultSet = stmt.executeQuery();
|
ResultSet resultSet = stmt.executeQuery();
|
||||||
|
|||||||
@ -138,11 +138,13 @@ public class MobileOperationDAOImpl implements MobileOperationDAO {
|
|||||||
String selectDBQuery =
|
String selectDBQuery =
|
||||||
"SELECT OPERATION_ID, FEATURE_CODE, CREATED_DATE FROM MBL_OPERATION WHERE OPERATION_ID = ?";
|
"SELECT OPERATION_ID, FEATURE_CODE, CREATED_DATE FROM MBL_OPERATION WHERE OPERATION_ID = ?";
|
||||||
stmt = conn.prepareStatement(selectDBQuery);
|
stmt = conn.prepareStatement(selectDBQuery);
|
||||||
stmt.setInt(1, operation.getOperationId());
|
stmt.setInt(1, operationId);
|
||||||
ResultSet resultSet = stmt.executeQuery();
|
ResultSet resultSet = stmt.executeQuery();
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
operation = new MobileOperation();
|
operation = new MobileOperation();
|
||||||
operation.setOperationId(resultSet.getInt(1));
|
operation.setOperationId(resultSet.getInt(1));
|
||||||
|
operation.setFeatureCode(resultSet.getString(2));
|
||||||
|
operation.setCreatedDate(resultSet.getLong(3));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
|||||||
@ -39,40 +39,6 @@ public class MobileDeviceManagementDAOUtil {
|
|||||||
|
|
||||||
private static final Log log = LogFactory.getLog(MobileDeviceManagementDAOUtil.class);
|
private static final Log log = LogFactory.getLog(MobileDeviceManagementDAOUtil.class);
|
||||||
|
|
||||||
/**
|
|
||||||
* Resolve data source from the data source definition.
|
|
||||||
*
|
|
||||||
* @param config Mobile data source configuration
|
|
||||||
* @return data source resolved from the data source definition
|
|
||||||
*/
|
|
||||||
public static DataSource resolveDataSource(MobileDataSourceConfig config) throws DeviceManagementException {
|
|
||||||
DataSource dataSource = null;
|
|
||||||
if (config == null) {
|
|
||||||
throw new RuntimeException("Device Management Repository data source configuration " +
|
|
||||||
"is null and thus, is not initialized");
|
|
||||||
}
|
|
||||||
JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion();
|
|
||||||
if (jndiConfig != null) {
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("Initializing Device Management Repository data source using the JNDI " +
|
|
||||||
"Lookup Definition");
|
|
||||||
}
|
|
||||||
List<JNDILookupDefinition.JNDIProperty> jndiPropertyList =
|
|
||||||
jndiConfig.getJndiProperties();
|
|
||||||
if (jndiPropertyList != null) {
|
|
||||||
Hashtable<Object, Object> jndiProperties = new Hashtable<Object, Object>();
|
|
||||||
for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) {
|
|
||||||
jndiProperties.put(prop.getName(), prop.getValue());
|
|
||||||
}
|
|
||||||
dataSource =
|
|
||||||
MobileDeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), jndiProperties);
|
|
||||||
} else {
|
|
||||||
dataSource = MobileDeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return dataSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DataSource lookupDataSource(String dataSourceName,
|
public static DataSource lookupDataSource(String dataSourceName,
|
||||||
final Hashtable<Object, Object> jndiProperties)
|
final Hashtable<Object, Object> jndiProperties)
|
||||||
throws DeviceManagementException {
|
throws DeviceManagementException {
|
||||||
@ -113,27 +79,6 @@ public class MobileDeviceManagementDAOUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the creation of mobile device management schema if -Dsetup has provided.
|
|
||||||
*
|
|
||||||
* @param dataSource Mobile data source
|
|
||||||
*/
|
|
||||||
public static void createDataSource(DataSource dataSource) {
|
|
||||||
String setupOption = System.getProperty("setup");
|
|
||||||
if (setupOption != null) {
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug(
|
|
||||||
"-Dsetup is enabled. Mobile Device management repository schema initialization is about " +
|
|
||||||
"to begin");
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
MobileDeviceManagementDAOUtil.setupMobileDeviceManagementSchema(dataSource);
|
|
||||||
} catch (DeviceManagementException e) {
|
|
||||||
log.error("Exception occurred while initializing mobile device management database schema", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the mobile device management schema.
|
* Creates the mobile device management schema.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -58,7 +58,7 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage
|
|||||||
mobileDeviceOperation.setDeviceId(deviceIdentifier.getId());
|
mobileDeviceOperation.setDeviceId(deviceIdentifier.getId());
|
||||||
status = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO()
|
status = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO()
|
||||||
.addMobileDeviceOperation(
|
.addMobileDeviceOperation(
|
||||||
new MobileDeviceOperation());
|
mobileDeviceOperation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (MobileDeviceManagementDAOException e) {
|
} catch (MobileDeviceManagementDAOException e) {
|
||||||
@ -75,6 +75,7 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage
|
|||||||
throws OperationManagementException {
|
throws OperationManagementException {
|
||||||
List<Operation> operations = new ArrayList<Operation>();
|
List<Operation> operations = new ArrayList<Operation>();
|
||||||
List<MobileDeviceOperation> mobileDeviceOperations = null;
|
List<MobileDeviceOperation> mobileDeviceOperations = null;
|
||||||
|
List<MobileOperationProperty> operationProperties = null;
|
||||||
MobileOperation mobileOperation = null;
|
MobileOperation mobileOperation = null;
|
||||||
try {
|
try {
|
||||||
mobileDeviceOperations = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO()
|
mobileDeviceOperations = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO()
|
||||||
@ -88,6 +89,11 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage
|
|||||||
mobileOperation = MobileDeviceManagementDAOFactory.getMobileOperationDAO()
|
mobileOperation = MobileDeviceManagementDAOFactory.getMobileOperationDAO()
|
||||||
.getMobileOperation(
|
.getMobileOperation(
|
||||||
operationId);
|
operationId);
|
||||||
|
operationProperties =
|
||||||
|
MobileDeviceManagementDAOFactory.getMobileOperationPropertyDAO()
|
||||||
|
.getAllMobileOperationPropertiesOfOperation(
|
||||||
|
operationId);
|
||||||
|
mobileOperation.setProperties(operationProperties);
|
||||||
operations.add(MobileDeviceManagementUtil
|
operations.add(MobileDeviceManagementUtil
|
||||||
.convertMobileOperationToOperation(mobileOperation));
|
.convertMobileOperationToOperation(mobileOperation));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,6 +31,7 @@ import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceConfigurationManager
|
|||||||
import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceManagementConfig;
|
import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceManagementConfig;
|
||||||
import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig;
|
import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig;
|
||||||
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.util.MobileDeviceManagementDAOUtil;
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidDeviceManagerService;
|
import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidDeviceManagerService;
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.ios.IOSDeviceManagerService;
|
import org.wso2.carbon.device.mgt.mobile.impl.ios.IOSDeviceManagerService;
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManagerService;
|
import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManagerService;
|
||||||
@ -54,112 +55,134 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class MobileDeviceManagementServiceComponent {
|
public class MobileDeviceManagementServiceComponent {
|
||||||
|
|
||||||
private ServiceRegistration androidServiceRegRef;
|
private ServiceRegistration androidServiceRegRef;
|
||||||
private ServiceRegistration iOSServiceRegRef;
|
private ServiceRegistration iOSServiceRegRef;
|
||||||
private ServiceRegistration windowsServiceRegRef;
|
private ServiceRegistration windowsServiceRegRef;
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(MobileDeviceManagementServiceComponent.class);
|
private static final Log log = LogFactory.getLog(MobileDeviceManagementServiceComponent.class);
|
||||||
|
|
||||||
protected void activate(ComponentContext ctx) {
|
protected void activate(ComponentContext ctx) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Activating Mobile Device Management Service Component");
|
log.debug("Activating Mobile Device Management Service Component");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
BundleContext bundleContext = ctx.getBundleContext();
|
BundleContext bundleContext = ctx.getBundleContext();
|
||||||
|
|
||||||
/* Initialize the datasource configuration */
|
/* Initialize the datasource configuration */
|
||||||
MobileDeviceConfigurationManager.getInstance().initConfig();
|
MobileDeviceConfigurationManager.getInstance().initConfig();
|
||||||
MobileDeviceManagementConfig config = MobileDeviceConfigurationManager.getInstance()
|
MobileDeviceManagementConfig config = MobileDeviceConfigurationManager.getInstance()
|
||||||
.getMobileDeviceManagementConfig();
|
.getMobileDeviceManagementConfig();
|
||||||
MobileDataSourceConfig dsConfig =
|
MobileDataSourceConfig dsConfig =
|
||||||
config.getMobileDeviceMgtRepository().getMobileDataSourceConfig();
|
config.getMobileDeviceMgtRepository().getMobileDataSourceConfig();
|
||||||
|
|
||||||
MobileDeviceManagementDAOFactory.setMobileDataSourceConfig(dsConfig);
|
MobileDeviceManagementDAOFactory.setMobileDataSourceConfig(dsConfig);
|
||||||
|
MobileDeviceManagementDAOFactory.init();
|
||||||
|
String setupOption = System.getProperty("setup");
|
||||||
|
if (setupOption != null) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug(
|
||||||
|
"-Dsetup is enabled. Mobile Device management repository schema initialization is about " +
|
||||||
|
"to begin");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
MobileDeviceManagementDAOUtil.setupMobileDeviceManagementSchema(
|
||||||
|
MobileDeviceManagementDAOFactory.getDataSource());
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
log.error(
|
||||||
|
"Exception occurred while initializing mobile device management database schema",
|
||||||
|
e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
androidServiceRegRef =
|
androidServiceRegRef =
|
||||||
bundleContext.registerService(DeviceManagerService.class.getName(),
|
bundleContext.registerService(DeviceManagerService.class.getName(),
|
||||||
new AndroidDeviceManagerService(), null);
|
new AndroidDeviceManagerService(), null);
|
||||||
iOSServiceRegRef =
|
iOSServiceRegRef =
|
||||||
bundleContext.registerService(DeviceManagerService.class.getName(),
|
bundleContext.registerService(DeviceManagerService.class.getName(),
|
||||||
new IOSDeviceManagerService(), null);
|
new IOSDeviceManagerService(), null);
|
||||||
windowsServiceRegRef =
|
windowsServiceRegRef =
|
||||||
bundleContext.registerService(DeviceManagerService.class.getName(),
|
bundleContext.registerService(DeviceManagerService.class.getName(),
|
||||||
new WindowsDeviceManagerService(), null);
|
new WindowsDeviceManagerService(), null);
|
||||||
|
|
||||||
/* Initialize all API configurations with corresponding API Providers */
|
/* Initialize all API configurations with corresponding API Providers */
|
||||||
this.initAPIConfigs();
|
this.initAPIConfigs();
|
||||||
/* Publish all mobile device management related JAX-RS services as APIs */
|
/* Publish all mobile device management related JAX-RS services as APIs */
|
||||||
this.publishAPIs();
|
this.publishAPIs();
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Mobile Device Management Service Component has been successfully activated");
|
log.debug(
|
||||||
}
|
"Mobile Device Management Service Component has been successfully activated");
|
||||||
} catch (Throwable e) {
|
}
|
||||||
log.error("Error occurred while activating Mobile Device Management Service Component", e);
|
} catch (Throwable e) {
|
||||||
}
|
log.error("Error occurred while activating Mobile Device Management Service Component",
|
||||||
}
|
e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void deactivate(ComponentContext ctx) {
|
protected void deactivate(ComponentContext ctx) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("De-activating Mobile Device Management Service Component");
|
log.debug("De-activating Mobile Device Management Service Component");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
BundleContext bundleContext = ctx.getBundleContext();
|
BundleContext bundleContext = ctx.getBundleContext();
|
||||||
|
|
||||||
androidServiceRegRef.unregister();
|
androidServiceRegRef.unregister();
|
||||||
iOSServiceRegRef.unregister();
|
iOSServiceRegRef.unregister();
|
||||||
windowsServiceRegRef.unregister();
|
windowsServiceRegRef.unregister();
|
||||||
|
|
||||||
/* Removing all APIs published upon start-up for mobile device management related JAX-RS
|
/* Removing all APIs published upon start-up for mobile device management related JAX-RS
|
||||||
services */
|
services */
|
||||||
this.removeAPIs();
|
this.removeAPIs();
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Mobile Device Management Service Component has been successfully de-activated");
|
log.debug(
|
||||||
}
|
"Mobile Device Management Service Component has been successfully de-activated");
|
||||||
} catch (Throwable e) {
|
}
|
||||||
log.error("Error occurred while de-activating Mobile Device Management bundle", e);
|
} catch (Throwable e) {
|
||||||
}
|
log.error("Error occurred while de-activating Mobile Device Management bundle", e);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void initAPIConfigs() throws DeviceManagementException {
|
private void initAPIConfigs() throws DeviceManagementException {
|
||||||
List<APIConfig> apiConfigs =
|
List<APIConfig> apiConfigs =
|
||||||
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
|
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
|
||||||
getApiPublisherConfig().getAPIs();
|
getApiPublisherConfig().getAPIs();
|
||||||
for (APIConfig apiConfig : apiConfigs) {
|
for (APIConfig apiConfig : apiConfigs) {
|
||||||
try {
|
try {
|
||||||
APIProvider provider = APIManagerFactory.getInstance().getAPIProvider(apiConfig.getOwner());
|
APIProvider provider =
|
||||||
apiConfig.init(provider);
|
APIManagerFactory.getInstance().getAPIProvider(apiConfig.getOwner());
|
||||||
} catch (APIManagementException e) {
|
apiConfig.init(provider);
|
||||||
throw new DeviceManagementException("Error occurred while initializing API Config '" +
|
} catch (APIManagementException e) {
|
||||||
apiConfig.getName() + "'", e);
|
throw new DeviceManagementException(
|
||||||
}
|
"Error occurred while initializing API Config '" +
|
||||||
}
|
apiConfig.getName() + "'", e);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void publishAPIs() throws DeviceManagementException {
|
private void publishAPIs() throws DeviceManagementException {
|
||||||
List<APIConfig> apiConfigs =
|
List<APIConfig> apiConfigs =
|
||||||
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
|
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
|
||||||
getApiPublisherConfig().getAPIs();
|
getApiPublisherConfig().getAPIs();
|
||||||
for (APIConfig apiConfig : apiConfigs) {
|
for (APIConfig apiConfig : apiConfigs) {
|
||||||
DeviceManagementAPIPublisherUtil.publishAPI(apiConfig);
|
DeviceManagementAPIPublisherUtil.publishAPI(apiConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeAPIs() throws DeviceManagementException {
|
private void removeAPIs() throws DeviceManagementException {
|
||||||
List<APIConfig> apiConfigs =
|
List<APIConfig> apiConfigs =
|
||||||
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
|
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
|
||||||
getApiPublisherConfig().getAPIs();
|
getApiPublisherConfig().getAPIs();
|
||||||
for (APIConfig apiConfig : apiConfigs) {
|
for (APIConfig apiConfig : apiConfigs) {
|
||||||
DeviceManagementAPIPublisherUtil.removeAPI(apiConfig);
|
DeviceManagementAPIPublisherUtil.removeAPI(apiConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setAPIManagerConfigurationService(APIManagerConfigurationService service) {
|
protected void setAPIManagerConfigurationService(APIManagerConfigurationService service) {
|
||||||
//do nothing
|
//do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void unsetAPIManagerConfigurationService(APIManagerConfigurationService service) {
|
protected void unsetAPIManagerConfigurationService(APIManagerConfigurationService service) {
|
||||||
//do nothing
|
//do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed 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.cdm.agent.utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constant values throughout the agent
|
||||||
|
*/
|
||||||
|
public class Constant {
|
||||||
|
public static final String USERNAME = "username";
|
||||||
|
public static final String PASSWORD = "password";
|
||||||
|
public static final String STATUS = "status";
|
||||||
|
public static final String RESPONSE = "response";
|
||||||
|
|
||||||
|
}
|
||||||
@ -210,7 +210,7 @@
|
|||||||
|
|
||||||
<!-- Copying Device Management related dbscripts -->
|
<!-- Copying Device Management related dbscripts -->
|
||||||
<fileSet>
|
<fileSet>
|
||||||
<directory>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/dbscripts/cdm</directory>
|
<directory>../distribution/src/repository/dbscripts/cdm</directory>
|
||||||
<outputDirectory>wso2cdm-${project.version}/dbscripts/cdm</outputDirectory>
|
<outputDirectory>wso2cdm-${project.version}/dbscripts/cdm</outputDirectory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>*/**</include>
|
<include>*/**</include>
|
||||||
@ -460,5 +460,15 @@
|
|||||||
<fileMode>644</fileMode>
|
<fileMode>644</fileMode>
|
||||||
</file>
|
</file>
|
||||||
|
|
||||||
|
<!-- Copying H2 database related files corresponding to default Mobile Device management repository schema -->
|
||||||
|
<file>
|
||||||
|
<source>
|
||||||
|
../distribution/src/repository/database/WSO2MobileDM_DB.h2.db
|
||||||
|
</source>
|
||||||
|
<outputDirectory>${pom.artifactId}-${pom.version}/repository/database</outputDirectory>
|
||||||
|
<destName>WSO2MobileDM_DB.h2.db</destName>
|
||||||
|
<fileMode>644</fileMode>
|
||||||
|
</file>
|
||||||
|
|
||||||
</files>
|
</files>
|
||||||
</assembly>
|
</assembly>
|
||||||
|
|||||||
Binary file not shown.
@ -23,4 +23,4 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE
|
|||||||
REFERENCES DM_DEVICE_TYPE (ID ) ON DELETE NO ACTION ON UPDATE NO ACTION
|
REFERENCES DM_DEVICE_TYPE (ID ) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||||
);
|
);
|
||||||
-- TO:DO - Remove this INSERT sql statement.
|
-- TO:DO - Remove this INSERT sql statement.
|
||||||
Insert into DM_DEVICE_TYPE (ID,NAME) VALUES (1, 'android');
|
Insert into DM_DEVICE_TYPE (NAME) VALUES ('android');
|
||||||
|
|||||||
@ -31,13 +31,8 @@ CREATE TABLE IF NOT EXISTS `MBL_FEATURE` (
|
|||||||
CREATE TABLE IF NOT EXISTS `MBL_OPERATION` (
|
CREATE TABLE IF NOT EXISTS `MBL_OPERATION` (
|
||||||
`OPERATION_ID` INT NOT NULL AUTO_INCREMENT ,
|
`OPERATION_ID` INT NOT NULL AUTO_INCREMENT ,
|
||||||
`FEATURE_CODE` VARCHAR(45) NOT NULL ,
|
`FEATURE_CODE` VARCHAR(45) NOT NULL ,
|
||||||
`CREATED_DATE` INT NULL ,
|
`CREATED_DATE` BIGINT NULL ,
|
||||||
PRIMARY KEY (`OPERATION_ID`) ,
|
PRIMARY KEY (`OPERATION_ID`));
|
||||||
CONSTRAINT `fk_MBL_OPERATION_MBL_FEATURES1`
|
|
||||||
FOREIGN KEY (`FEATURE_CODE` )
|
|
||||||
REFERENCES `MBL_FEATURE` (`CODE` )
|
|
||||||
ON DELETE NO ACTION
|
|
||||||
ON UPDATE NO ACTION);
|
|
||||||
|
|
||||||
-- -----------------------------------------------------
|
-- -----------------------------------------------------
|
||||||
-- Table `MBL_DEVICE_OPERATION_MAPPING`
|
-- Table `MBL_DEVICE_OPERATION_MAPPING`
|
||||||
@ -45,8 +40,8 @@ CREATE TABLE IF NOT EXISTS `MBL_OPERATION` (
|
|||||||
CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPPING` (
|
CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPPING` (
|
||||||
`DEVICE_ID` VARCHAR(45) NOT NULL ,
|
`DEVICE_ID` VARCHAR(45) NOT NULL ,
|
||||||
`OPERATION_ID` INT NOT NULL ,
|
`OPERATION_ID` INT NOT NULL ,
|
||||||
`SENT_DATE` INT NULL ,
|
`SENT_DATE` BIGINT NULL ,
|
||||||
`RECEIVED_DATE` INT NULL ,
|
`RECEIVED_DATE` BIGINT NULL ,
|
||||||
PRIMARY KEY (`DEVICE_ID`, `OPERATION_ID`) ,
|
PRIMARY KEY (`DEVICE_ID`, `OPERATION_ID`) ,
|
||||||
CONSTRAINT `fk_MBL_DEVICE_OPERATION_MBL_DEVICE`
|
CONSTRAINT `fk_MBL_DEVICE_OPERATION_MBL_DEVICE`
|
||||||
FOREIGN KEY (`DEVICE_ID` )
|
FOREIGN KEY (`DEVICE_ID` )
|
||||||
|
|||||||
@ -10,6 +10,8 @@ CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
|
|||||||
`OS_VERSION` VARCHAR(45) NULL DEFAULT NULL ,
|
`OS_VERSION` VARCHAR(45) NULL DEFAULT NULL ,
|
||||||
`DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL ,
|
`DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL ,
|
||||||
`VENDOR` VARCHAR(45) NULL DEFAULT NULL ,
|
`VENDOR` VARCHAR(45) NULL DEFAULT NULL ,
|
||||||
|
`LATITUDE` VARCHAR(45) NULL DEFAULT NULL,
|
||||||
|
`LONGITUDE` VARCHAR(45) NULL DEFAULT NULL,
|
||||||
PRIMARY KEY (`MOBILE_DEVICE_ID`) );
|
PRIMARY KEY (`MOBILE_DEVICE_ID`) );
|
||||||
|
|
||||||
|
|
||||||
@ -18,7 +20,7 @@ CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
|
|||||||
-- -----------------------------------------------------
|
-- -----------------------------------------------------
|
||||||
CREATE TABLE IF NOT EXISTS `MBL_FEATURE` (
|
CREATE TABLE IF NOT EXISTS `MBL_FEATURE` (
|
||||||
`FEATURE_ID` INT NOT NULL AUTO_INCREMENT ,
|
`FEATURE_ID` INT NOT NULL AUTO_INCREMENT ,
|
||||||
`CODE` VARCHAR(45) NULL ,
|
`CODE` VARCHAR(45) NOT NULL ,
|
||||||
`NAME` VARCHAR(100) NULL ,
|
`NAME` VARCHAR(100) NULL ,
|
||||||
`DESCRIPTION` VARCHAR(200) NULL ,
|
`DESCRIPTION` VARCHAR(200) NULL ,
|
||||||
PRIMARY KEY (`FEATURE_ID`) );
|
PRIMARY KEY (`FEATURE_ID`) );
|
||||||
@ -28,23 +30,18 @@ CREATE TABLE IF NOT EXISTS `MBL_FEATURE` (
|
|||||||
-- -----------------------------------------------------
|
-- -----------------------------------------------------
|
||||||
CREATE TABLE IF NOT EXISTS `MBL_OPERATION` (
|
CREATE TABLE IF NOT EXISTS `MBL_OPERATION` (
|
||||||
`OPERATION_ID` INT NOT NULL AUTO_INCREMENT ,
|
`OPERATION_ID` INT NOT NULL AUTO_INCREMENT ,
|
||||||
`FEATURE_CODE` VARCHAR(45) NULL ,
|
`FEATURE_CODE` VARCHAR(45) NOT NULL ,
|
||||||
`CREATED_DATE` INT NULL ,
|
`CREATED_DATE` LONG NULL ,
|
||||||
PRIMARY KEY (`OPERATION_ID`) ,
|
PRIMARY KEY (`OPERATION_ID`));
|
||||||
CONSTRAINT `fk_MBL_OPERATION_MBL_FEATURES1`
|
|
||||||
FOREIGN KEY (`FEATURE_CODE` )
|
|
||||||
REFERENCES `MBL_FEATURE` (`CODE` )
|
|
||||||
ON DELETE NO ACTION
|
|
||||||
ON UPDATE NO ACTION);
|
|
||||||
|
|
||||||
-- -----------------------------------------------------
|
-- -----------------------------------------------------
|
||||||
-- Table `MBL_DEVICE_OPERATION_MAPING`
|
-- Table `MBL_DEVICE_OPERATION_MAPPING`
|
||||||
-- -----------------------------------------------------
|
-- -----------------------------------------------------
|
||||||
CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPING` (
|
CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPPING` (
|
||||||
`DEVICE_ID` VARCHAR(45) NOT NULL ,
|
`DEVICE_ID` VARCHAR(45) NOT NULL ,
|
||||||
`OPERATION_ID` INT NOT NULL ,
|
`OPERATION_ID` INT NOT NULL ,
|
||||||
`SENT_DATE` INT NULL ,
|
`SENT_DATE` LONG NULL ,
|
||||||
`RECEIVED_DATE` INT NULL ,
|
`RECEIVED_DATE` LONG NULL ,
|
||||||
PRIMARY KEY (`DEVICE_ID`, `OPERATION_ID`) ,
|
PRIMARY KEY (`DEVICE_ID`, `OPERATION_ID`) ,
|
||||||
CONSTRAINT `fk_MBL_DEVICE_OPERATION_MBL_DEVICE`
|
CONSTRAINT `fk_MBL_DEVICE_OPERATION_MBL_DEVICE`
|
||||||
FOREIGN KEY (`DEVICE_ID` )
|
FOREIGN KEY (`DEVICE_ID` )
|
||||||
@ -61,11 +58,10 @@ CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPING` (
|
|||||||
-- Table `MBL_OPERATION_PROPERTY`
|
-- Table `MBL_OPERATION_PROPERTY`
|
||||||
-- -----------------------------------------------------
|
-- -----------------------------------------------------
|
||||||
CREATE TABLE IF NOT EXISTS `MBL_OPERATION_PROPERTY` (
|
CREATE TABLE IF NOT EXISTS `MBL_OPERATION_PROPERTY` (
|
||||||
`OPERATION_PROPERTY_ID` INT NOT NULL AUTO_INCREMENT ,
|
`OPERATION_ID` INT NOT NULL ,
|
||||||
`OPERATION_ID` INT NULL ,
|
`PROPERTY` VARCHAR(45) NOT NULL ,
|
||||||
`PROPERTY_ID` INT NULL ,
|
|
||||||
`VALUE` TEXT NULL ,
|
`VALUE` TEXT NULL ,
|
||||||
PRIMARY KEY (`OPERATION_PROPERTY_ID`) ,
|
PRIMARY KEY (`OPERATION_ID`, `PROPERTY`) ,
|
||||||
CONSTRAINT `fk_MBL_OPERATION_PROPERTY_MBL_OPERATION1`
|
CONSTRAINT `fk_MBL_OPERATION_PROPERTY_MBL_OPERATION1`
|
||||||
FOREIGN KEY (`OPERATION_ID` )
|
FOREIGN KEY (`OPERATION_ID` )
|
||||||
REFERENCES `MBL_OPERATION` (`OPERATION_ID` )
|
REFERENCES `MBL_OPERATION` (`OPERATION_ID` )
|
||||||
@ -76,13 +72,11 @@ CREATE TABLE IF NOT EXISTS `MBL_OPERATION_PROPERTY` (
|
|||||||
-- Table `MBL_FEATURE_PROPERTY`
|
-- Table `MBL_FEATURE_PROPERTY`
|
||||||
-- -----------------------------------------------------
|
-- -----------------------------------------------------
|
||||||
CREATE TABLE IF NOT EXISTS `MBL_FEATURE_PROPERTY` (
|
CREATE TABLE IF NOT EXISTS `MBL_FEATURE_PROPERTY` (
|
||||||
`PROPERTY_ID` INT NOT NULL AUTO_INCREMENT ,
|
`PROPERTY` VARCHAR(45) NOT NULL ,
|
||||||
`PROPERTY` VARCHAR(100) NULL ,
|
`FEATURE_ID` VARCHAR(45) NOT NULL ,
|
||||||
`FEATURE_ID` VARCHAR(45) NULL ,
|
PRIMARY KEY (`PROPERTY`) ,
|
||||||
PRIMARY KEY (`PROPERTY_ID`) ,
|
|
||||||
CONSTRAINT `fk_MBL_FEATURE_PROPERTY_MBL_FEATURE1`
|
CONSTRAINT `fk_MBL_FEATURE_PROPERTY_MBL_FEATURE1`
|
||||||
FOREIGN KEY (`FEATURE_ID` )
|
FOREIGN KEY (`FEATURE_ID` )
|
||||||
REFERENCES `MBL_FEATURE` (`FEATURE_ID` )
|
REFERENCES `MBL_FEATURE` (`FEATURE_ID` )
|
||||||
ON DELETE NO ACTION
|
ON DELETE NO ACTION
|
||||||
ON UPDATE NO ACTION);
|
ON UPDATE NO ACTION);
|
||||||
|
|
||||||
|
|||||||
@ -276,7 +276,7 @@ int drawable repeat_bg 0x7f020087
|
|||||||
int drawable top_bar 0x7f020088
|
int drawable top_bar 0x7f020088
|
||||||
int drawable wifi 0x7f020089
|
int drawable wifi 0x7f020089
|
||||||
int drawable wipe 0x7f02008a
|
int drawable wipe 0x7f02008a
|
||||||
int id TextView01 0x7f060090
|
int id TextView01 0x7f060091
|
||||||
int id abs__action_bar 0x7f06004e
|
int id abs__action_bar 0x7f06004e
|
||||||
int id abs__action_bar_container 0x7f06004d
|
int id abs__action_bar_container 0x7f06004d
|
||||||
int id abs__action_bar_subtitle 0x7f06003d
|
int id abs__action_bar_subtitle 0x7f06003d
|
||||||
@ -317,42 +317,45 @@ int id abs__textButton 0x7f06003f
|
|||||||
int id abs__title 0x7f060047
|
int id abs__title 0x7f060047
|
||||||
int id abs__titleDivider 0x7f060048
|
int id abs__titleDivider 0x7f060048
|
||||||
int id abs__up 0x7f06000b
|
int id abs__up 0x7f06000b
|
||||||
int id action_settings 0x7f060094
|
int id action_settings 0x7f060095
|
||||||
int id background_container 0x7f06001f
|
int id background_container 0x7f06001f
|
||||||
int id blocks_now 0x7f06001e
|
int id blocks_now 0x7f06001e
|
||||||
int id blocks_ruler 0x7f06001d
|
int id blocks_ruler 0x7f06001d
|
||||||
int id btnEnroll 0x7f060082
|
int id btnEnroll 0x7f060082
|
||||||
int id btnLogin 0x7f06008f
|
int id btnLogin 0x7f060090
|
||||||
int id btnOK 0x7f060064
|
int id btnOK 0x7f060064
|
||||||
int id btnRefresh 0x7f06007d
|
int id btnRefresh 0x7f06007d
|
||||||
int id btnRegister 0x7f060070
|
int id btnRegister 0x7f060070
|
||||||
int id btnReset 0x7f06007e
|
int id btnReset 0x7f06007e
|
||||||
int id btnSetPin 0x7f060087
|
int id btnSetPin 0x7f060087
|
||||||
|
int id btnStartRegistration 0x7f06008b
|
||||||
int id btnTryAgain 0x7f060073
|
int id btnTryAgain 0x7f060073
|
||||||
int id btnUnreg 0x7f060065
|
int id btnUnreg 0x7f060065
|
||||||
int id btnUnregister 0x7f060088
|
int id btnUnregister 0x7f060088
|
||||||
int id button_layout 0x7f06008c
|
int id button_layout 0x7f06008d
|
||||||
int id debug_log 0x7f06009a
|
int id debug_log 0x7f06009b
|
||||||
int id dialogButtonCancel 0x7f06008e
|
int id dialogButtonCancel 0x7f06008f
|
||||||
int id dialogButtonOK 0x7f06008d
|
int id dialogButtonOK 0x7f06008e
|
||||||
int id dialog_discard_confirm 0x7f06001a
|
int id dialog_discard_confirm 0x7f06001a
|
||||||
int id dialog_moderator 0x7f06001b
|
int id dialog_moderator 0x7f06001b
|
||||||
int id dialog_wave 0x7f06001c
|
int id dialog_wave 0x7f06001c
|
||||||
int id disableHome 0x7f060009
|
int id disableHome 0x7f060009
|
||||||
int id editText2 0x7f06006c
|
|
||||||
int id edit_query 0x7f060053
|
int id edit_query 0x7f060053
|
||||||
int id enrollPanel 0x7f060081
|
int id enrollPanel 0x7f060081
|
||||||
int id error 0x7f060072
|
int id error 0x7f060072
|
||||||
int id etServerIP 0x7f06008a
|
int id etDomain 0x7f06006a
|
||||||
|
int id etPassword 0x7f06006c
|
||||||
|
int id etUsername 0x7f06006b
|
||||||
|
int id evServerIP 0x7f06008a
|
||||||
int id footer 0x7f060071
|
int id footer 0x7f060071
|
||||||
int id footerlogo 0x7f060068
|
int id footerlogo 0x7f060068
|
||||||
int id fragment_container 0x7f060034
|
int id fragment_container 0x7f060034
|
||||||
int id gridview 0x7f060014
|
int id gridview 0x7f060014
|
||||||
int id homeAsUp 0x7f060006
|
int id homeAsUp 0x7f060006
|
||||||
int id incompatibleError 0x7f060074
|
int id incompatibleError 0x7f060074
|
||||||
int id info 0x7f060097
|
int id info 0x7f060098
|
||||||
int id info_setting 0x7f060098
|
int id info_setting 0x7f060099
|
||||||
int id ip_setting 0x7f060096
|
int id ip_setting 0x7f060097
|
||||||
int id layout_topbar 0x7f060067
|
int id layout_topbar 0x7f060067
|
||||||
int id lblPin 0x7f060084
|
int id lblPin 0x7f060084
|
||||||
int id linInner 0x7f060062
|
int id linInner 0x7f060062
|
||||||
@ -361,25 +364,24 @@ int id linearLayoutText 0x7f060080
|
|||||||
int id listMode 0x7f060002
|
int id listMode 0x7f060002
|
||||||
int id listview 0x7f060060
|
int id listview 0x7f060060
|
||||||
int id logo 0x7f06005f
|
int id logo 0x7f06005f
|
||||||
int id more 0x7f060095
|
int id more 0x7f060096
|
||||||
int id normal 0x7f060001
|
int id normal 0x7f060001
|
||||||
int id notify 0x7f060091
|
int id notify 0x7f060092
|
||||||
int id option_button 0x7f06007c
|
int id option_button 0x7f06007c
|
||||||
int id pin_setting 0x7f060099
|
int id pin_setting 0x7f06009a
|
||||||
int id preference_brand_view 0x7f06002d
|
int id preference_brand_view 0x7f06002d
|
||||||
int id preference_empty_view 0x7f06002c
|
int id preference_empty_view 0x7f06002c
|
||||||
int id radioBYOD 0x7f06006e
|
int id radioBYOD 0x7f06006e
|
||||||
int id radioCOPE 0x7f06006f
|
int id radioCOPE 0x7f06006f
|
||||||
int id radioGroupType 0x7f06006d
|
int id radioGroupType 0x7f06006d
|
||||||
int id rowImage 0x7f060092
|
int id rowImage 0x7f060093
|
||||||
int id rowTextView 0x7f060093
|
int id rowTextView 0x7f060094
|
||||||
int id scroller 0x7f060061
|
int id scroller 0x7f060061
|
||||||
int id setting_invite_email_button 0x7f060030
|
int id setting_invite_email_button 0x7f060030
|
||||||
int id setting_invite_email_edittext 0x7f06002f
|
int id setting_invite_email_edittext 0x7f06002f
|
||||||
int id setting_invite_email_imageview 0x7f060031
|
int id setting_invite_email_imageview 0x7f060031
|
||||||
int id setting_invite_email_layout 0x7f06002e
|
int id setting_invite_email_layout 0x7f06002e
|
||||||
int id setting_invite_email_textview 0x7f060032
|
int id setting_invite_email_textview 0x7f060032
|
||||||
int id severAddressLabel 0x7f060089
|
|
||||||
int id sg_button1 0x7f060039
|
int id sg_button1 0x7f060039
|
||||||
int id sg_button2 0x7f06003a
|
int id sg_button2 0x7f06003a
|
||||||
int id sg_button3 0x7f06003b
|
int id sg_button3 0x7f06003b
|
||||||
@ -407,14 +409,14 @@ int id swipeable_bottom 0x7f060010
|
|||||||
int id swipeable_container 0x7f060012
|
int id swipeable_container 0x7f060012
|
||||||
int id swipeable_top 0x7f060011
|
int id swipeable_top 0x7f060011
|
||||||
int id tabMode 0x7f060003
|
int id tabMode 0x7f060003
|
||||||
int id text 0x7f06008b
|
int id text 0x7f06008c
|
||||||
int id title_bar_layout 0x7f060020
|
int id title_bar_layout 0x7f060020
|
||||||
int id title_container 0x7f060016
|
int id title_container 0x7f060016
|
||||||
int id title_logo 0x7f060017
|
int id title_logo 0x7f060017
|
||||||
int id title_option 0x7f060019
|
int id title_option 0x7f060019
|
||||||
int id title_text 0x7f060018
|
int id title_text 0x7f060018
|
||||||
|
int id tvSeverAddress 0x7f060089
|
||||||
int id txtDevice 0x7f060076
|
int id txtDevice 0x7f060076
|
||||||
int id txtDomain 0x7f06006a
|
|
||||||
int id txtId 0x7f060075
|
int id txtId 0x7f060075
|
||||||
int id txtLog 0x7f06007f
|
int id txtLog 0x7f06007f
|
||||||
int id txtMessage 0x7f060063
|
int id txtMessage 0x7f060063
|
||||||
@ -428,7 +430,6 @@ int id txtRoot 0x7f06007b
|
|||||||
int id txtSDK 0x7f060079
|
int id txtSDK 0x7f060079
|
||||||
int id useLogo 0x7f060004
|
int id useLogo 0x7f060004
|
||||||
int id user_edit_location 0x7f060033
|
int id user_edit_location 0x7f060033
|
||||||
int id username 0x7f06006b
|
|
||||||
int id webview 0x7f060015
|
int id webview 0x7f060015
|
||||||
int id wrap_content 0x7f060000
|
int id wrap_content 0x7f060000
|
||||||
int integer abs__max_action_buttons 0x7f0a0000
|
int integer abs__max_action_buttons 0x7f0a0000
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="5dp"
|
android:layout_margin="5dp"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:id="@+id/txtDomain"
|
android:id="@+id/etDomain"
|
||||||
android:hint="Domain"
|
android:hint="Domain"
|
||||||
android:textColor="@android:color/black"
|
android:textColor="@android:color/black"
|
||||||
android:inputType="text" />
|
android:inputType="text" />
|
||||||
@ -37,7 +37,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="5dp"
|
android:layout_margin="5dp"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:id="@+id/username"
|
android:id="@+id/etUsername"
|
||||||
android:hint="Username"
|
android:hint="Username"
|
||||||
android:textColor="@android:color/black"
|
android:textColor="@android:color/black"
|
||||||
android:inputType="textEmailAddress" />
|
android:inputType="textEmailAddress" />
|
||||||
@ -47,7 +47,7 @@
|
|||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:inputType="textPassword"
|
android:inputType="textPassword"
|
||||||
android:id="@+id/editText2"
|
android:id="@+id/etPassword"
|
||||||
android:layout_margin="5dp"
|
android:layout_margin="5dp"
|
||||||
android:textColor="@android:color/black"
|
android:textColor="@android:color/black"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@ -71,7 +71,7 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<!-- Login Form Ends -->
|
<!-- Login Form Ends -->
|
||||||
|
|
||||||
<TextView android:id="@+id/severAddressLabel"
|
<TextView android:id="@+id/tvSeverAddress"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_below="@+id/linearLayout1"
|
android:layout_below="@+id/linearLayout1"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="10dp"
|
||||||
@ -84,10 +84,10 @@
|
|||||||
android:text="@string/registration_heading"/>
|
android:text="@string/registration_heading"/>
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/etServerIP"
|
android:id="@+id/evServerIP"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/severAddressLabel"
|
android:layout_below="@+id/tvSeverAddress"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_marginLeft="22dp"
|
android:layout_marginLeft="22dp"
|
||||||
android:ems="10"
|
android:ems="10"
|
||||||
@ -96,14 +96,14 @@
|
|||||||
</EditText>
|
</EditText>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/startRegistration"
|
android:id="@+id/btnStartRegistration"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
style="@style/ButtonText"
|
style="@style/ButtonText"
|
||||||
android:background="@drawable/btn_orange"
|
android:background="@drawable/btn_orange"
|
||||||
android:layout_below="@+id/etServerIP"
|
android:layout_below="@+id/evServerIP"
|
||||||
android:text="Start Registration" />
|
android:text="Start Registration" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|||||||
@ -28,6 +28,7 @@ import org.wso2.cdm.agent.proxy.IdentityProxy;
|
|||||||
import org.wso2.cdm.agent.services.AlarmReceiver;
|
import org.wso2.cdm.agent.services.AlarmReceiver;
|
||||||
import org.wso2.cdm.agent.utils.CommonDialogUtils;
|
import org.wso2.cdm.agent.utils.CommonDialogUtils;
|
||||||
import org.wso2.cdm.agent.utils.CommonUtilities;
|
import org.wso2.cdm.agent.utils.CommonUtilities;
|
||||||
|
import org.wso2.cdm.agent.utils.Constant;
|
||||||
import org.wso2.cdm.agent.utils.HTTPConnectorUtils;
|
import org.wso2.cdm.agent.utils.HTTPConnectorUtils;
|
||||||
import org.wso2.cdm.agent.utils.Preference;
|
import org.wso2.cdm.agent.utils.Preference;
|
||||||
import org.wso2.cdm.agent.utils.ServerUtils;
|
import org.wso2.cdm.agent.utils.ServerUtils;
|
||||||
@ -66,24 +67,26 @@ import com.actionbarsherlock.view.MenuItem;
|
|||||||
import com.google.android.gcm.GCMRegistrar;
|
import com.google.android.gcm.GCMRegistrar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activity that captures username, password and device ownership details
|
* Activity that captures username, password and device ownership details.
|
||||||
*/
|
*/
|
||||||
public class AuthenticationActivity extends SherlockActivity implements APIAccessCallBack,
|
public class AuthenticationActivity extends SherlockActivity implements APIAccessCallBack,
|
||||||
APIResultCallBack {
|
APIResultCallBack {
|
||||||
|
|
||||||
|
|
||||||
private String TAG = AuthenticationActivity.class.getSimpleName();
|
private String TAG = AuthenticationActivity.class.getSimpleName();
|
||||||
|
|
||||||
Button authenticate;
|
Button btnRegister;
|
||||||
EditText username;
|
EditText etUsername;
|
||||||
EditText txtDomain;
|
EditText etDomain;
|
||||||
EditText password;
|
EditText etPassword;
|
||||||
RadioButton radioBYOD, radioCOPE;
|
RadioButton radioBYOD, radioCOPE;
|
||||||
String deviceType;
|
String deviceType;
|
||||||
Context context;
|
Context context;
|
||||||
String senderId = "";
|
String senderId;
|
||||||
String usernameForRegister = "";
|
String usernameForRegister;
|
||||||
String usernameVal;
|
String usernameVal;
|
||||||
String passwordVal;
|
String passwordVal;
|
||||||
|
String domain;
|
||||||
ProgressDialog progressDialog;
|
ProgressDialog progressDialog;
|
||||||
AlertDialog.Builder alertDialog;
|
AlertDialog.Builder alertDialog;
|
||||||
|
|
||||||
@ -103,21 +106,21 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
|
|||||||
|
|
||||||
context = AuthenticationActivity.this;
|
context = AuthenticationActivity.this;
|
||||||
deviceType = getResources().getString(R.string.device_enroll_type_byod);
|
deviceType = getResources().getString(R.string.device_enroll_type_byod);
|
||||||
txtDomain = (EditText) findViewById(R.id.txtDomain);
|
etDomain = (EditText) findViewById(R.id.etDomain);
|
||||||
username = (EditText) findViewById(R.id.username);
|
etUsername = (EditText) findViewById(R.id.etUsername);
|
||||||
password = (EditText) findViewById(R.id.editText2);
|
etPassword = (EditText) findViewById(R.id.etPassword);
|
||||||
radioBYOD = (RadioButton) findViewById(R.id.radioBYOD);
|
radioBYOD = (RadioButton) findViewById(R.id.radioBYOD);
|
||||||
radioCOPE = (RadioButton) findViewById(R.id.radioCOPE);
|
radioCOPE = (RadioButton) findViewById(R.id.radioCOPE);
|
||||||
txtDomain.setFocusable(true);
|
etDomain.setFocusable(true);
|
||||||
txtDomain.requestFocus();
|
etDomain.requestFocus();
|
||||||
authenticate = (Button) findViewById(R.id.btnRegister);
|
btnRegister = (Button) findViewById(R.id.btnRegister);
|
||||||
authenticate.setEnabled(false);
|
btnRegister.setEnabled(false);
|
||||||
authenticate.setOnClickListener(onClickAuthenticate);
|
btnRegister.setOnClickListener(onClickAuthenticate);
|
||||||
// change button color background till user enters a valid input
|
// change button color background till user enters a valid input
|
||||||
authenticate.setBackground(getResources().getDrawable(R.drawable.btn_grey));
|
btnRegister.setBackground(getResources().getDrawable(R.drawable.btn_grey));
|
||||||
authenticate.setTextColor(getResources().getColor(R.color.black));
|
btnRegister.setTextColor(getResources().getColor(R.color.black));
|
||||||
|
|
||||||
username.addTextChangedListener(new TextWatcher() {
|
etUsername.addTextChangedListener(new TextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
}
|
}
|
||||||
@ -133,7 +136,7 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
password.addTextChangedListener(new TextWatcher() {
|
etPassword.addTextChangedListener(new TextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
}
|
}
|
||||||
@ -155,18 +158,14 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if (username.getText() != null && !username.getText().toString().trim().equals("") &&
|
if (etUsername.getText() != null &&
|
||||||
password.getText() != null && !password.getText().toString().trim().equals("")) {
|
!etUsername.getText().toString().trim().equals("") &&
|
||||||
|
etPassword.getText() != null && !etPassword.getText().toString().trim().equals("")) {
|
||||||
|
|
||||||
passwordVal = password.getText().toString().trim();
|
passwordVal = etPassword.getText().toString().trim();
|
||||||
if (txtDomain.getText() != null &&
|
usernameVal = etUsername.getText().toString().trim();
|
||||||
!txtDomain.getText().toString().trim().equals("")) {
|
if (etDomain.getText() != null && !etDomain.getText().toString().trim().equals("")) {
|
||||||
usernameVal =
|
usernameVal += "@" + etDomain.getText().toString().trim();
|
||||||
username.getText().toString().trim() + "@" +
|
|
||||||
txtDomain.getText().toString().trim();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
usernameVal = username.getText().toString().trim();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (radioBYOD.isChecked()) {
|
if (radioBYOD.isChecked()) {
|
||||||
@ -174,22 +173,24 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
|
|||||||
} else {
|
} else {
|
||||||
deviceType = getResources().getString(R.string.device_enroll_type_cope);
|
deviceType = getResources().getString(R.string.device_enroll_type_cope);
|
||||||
}
|
}
|
||||||
|
StringBuilder messageBuilder = new StringBuilder();
|
||||||
|
messageBuilder.append(getResources().getString(R.string.dialog_init_middle));
|
||||||
|
messageBuilder.append(" ");
|
||||||
|
messageBuilder.append(deviceType);
|
||||||
|
messageBuilder.append(" ");
|
||||||
|
messageBuilder.append(getResources().getString(R.string.dialog_init_end));
|
||||||
alertDialog =
|
alertDialog =
|
||||||
CommonDialogUtils.getAlertDialogWithTwoButtonAndTitle(context,
|
CommonDialogUtils.getAlertDialogWithTwoButtonAndTitle(context,
|
||||||
getResources().getString(R.string.dialog_init_device_type),
|
getResources().getString(R.string.dialog_init_device_type),
|
||||||
getResources().getString(R.string.dialog_init_middle) +
|
messageBuilder.toString(),
|
||||||
" " +
|
|
||||||
deviceType +
|
|
||||||
" " +
|
|
||||||
getResources().getString(R.string.dialog_init_end),
|
|
||||||
getResources().getString(R.string.yes),
|
getResources().getString(R.string.yes),
|
||||||
|
|
||||||
getResources().getString(R.string.no),
|
getResources().getString(R.string.no),
|
||||||
dialogClickListener,
|
dialogClickListener,
|
||||||
dialogClickListener);
|
dialogClickListener);
|
||||||
alertDialog.show();
|
alertDialog.show();
|
||||||
} else {
|
} else {
|
||||||
if (username.getText() != null && !username.getText().toString().trim().equals("")) {
|
if (etUsername.getText() != null &&
|
||||||
|
!etUsername.getText().toString().trim().equals("")) {
|
||||||
Toast.makeText(context,
|
Toast.makeText(context,
|
||||||
getResources().getString(R.string.toast_error_password),
|
getResources().getString(R.string.toast_error_password),
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
@ -250,14 +251,14 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
|
|||||||
Map<String, String> requestParametres =
|
Map<String, String> requestParametres =
|
||||||
new HashMap<String, String>();
|
new HashMap<String, String>();
|
||||||
|
|
||||||
requestParametres.put("username",
|
requestParametres.put(Constant.USERNAME,
|
||||||
usernameVal);
|
usernameVal);
|
||||||
requestParametres.put("password",
|
requestParametres.put(Constant.PASSWORD,
|
||||||
passwordVal);
|
passwordVal);
|
||||||
response =
|
response =
|
||||||
HTTPConnectorUtils.postData(context,
|
HTTPConnectorUtils.postData(context,
|
||||||
CommonUtilities.SERVER_URL +
|
CommonUtilities.SERVER_URL +
|
||||||
CommonUtilities.SERVER_AUTHENTICATION_ENDPOINT,
|
CommonUtilities.SERVER_AUTHENTICATION_ENDPOINT,
|
||||||
requestParametres);
|
requestParametres);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@ -274,55 +275,7 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Map<String, String> result) {
|
protected void onPostExecute(Map<String, String> result) {
|
||||||
JSONObject response =
|
authenticateResponse(result);
|
||||||
null;
|
|
||||||
if (result != null) {
|
|
||||||
String responseStatus =
|
|
||||||
result.get("status");
|
|
||||||
try {
|
|
||||||
if (responseStatus != null) {
|
|
||||||
if (responseStatus.equalsIgnoreCase(CommonUtilities.REQUEST_SUCCESSFUL)) {
|
|
||||||
response =
|
|
||||||
new JSONObject(
|
|
||||||
result.get("response"));
|
|
||||||
senderId =
|
|
||||||
response.getString("senderId");
|
|
||||||
getLicense();
|
|
||||||
} else if (responseStatus.equalsIgnoreCase(CommonUtilities.UNAUTHORIZED_ACCESS)) {
|
|
||||||
CommonDialogUtils.stopProgressDialog(progressDialog);
|
|
||||||
alertDialog =
|
|
||||||
CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(context,
|
|
||||||
getResources().getString(R.string.title_head_authentication_error),
|
|
||||||
getResources().getString(R.string.error_authentication_failed),
|
|
||||||
getResources().getString(R.string.button_ok),
|
|
||||||
dialogClickListener);
|
|
||||||
} else if (responseStatus.trim()
|
|
||||||
.equals(CommonUtilities.INTERNAL_SERVER_ERROR)) {
|
|
||||||
CommonDialogUtils.stopProgressDialog(progressDialog);
|
|
||||||
showInternalServerErrorMessage();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Log.e(TAG,
|
|
||||||
"Status: " +
|
|
||||||
responseStatus);
|
|
||||||
showAuthCommonErrorMessage();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Log.e(TAG,
|
|
||||||
"The value of status is null in authenticate()");
|
|
||||||
showAuthCommonErrorMessage();
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (JSONException e) {
|
|
||||||
Log.e(TAG,
|
|
||||||
e.getMessage());
|
|
||||||
showAuthCommonErrorMessage();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Log.e(TAG,
|
|
||||||
"The result is null in authenticate()");
|
|
||||||
showAuthCommonErrorMessage();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,14 +284,52 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
|
|||||||
mLicenseTask.execute();
|
mLicenseTask.execute();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the response received from server for the authentication request.
|
||||||
|
* @param result Received response from server.
|
||||||
|
*/
|
||||||
|
private void authenticateResponse(Map<String, String> result){
|
||||||
|
if (result != null) {
|
||||||
|
String responseStatus =
|
||||||
|
result.get(Constant.STATUS);
|
||||||
|
if (responseStatus != null) {
|
||||||
|
if (responseStatus.equalsIgnoreCase(CommonUtilities.REQUEST_SUCCESSFUL)) {
|
||||||
|
getLicense();
|
||||||
|
} else if (responseStatus.equalsIgnoreCase(CommonUtilities.UNAUTHORIZED_ACCESS)) {
|
||||||
|
CommonDialogUtils.stopProgressDialog(progressDialog);
|
||||||
|
alertDialog =
|
||||||
|
CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(context,
|
||||||
|
getResources().getString(R.string.title_head_authentication_error),
|
||||||
|
getResources().getString(R.string.error_authentication_failed),
|
||||||
|
getResources().getString(R.string.button_ok),
|
||||||
|
dialogClickListener);
|
||||||
|
} else if (responseStatus.trim()
|
||||||
|
.equals(CommonUtilities.INTERNAL_SERVER_ERROR)) {
|
||||||
|
Log.e(TAG, "Error: Internal server error");
|
||||||
|
showInternalServerErrorMessage();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "Status: " + responseStatus);
|
||||||
|
showAuthCommonErrorMessage();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "The value of status is null in authenticating");
|
||||||
|
showAuthCommonErrorMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "The result is null in authenticating");
|
||||||
|
showAuthCommonErrorMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize get device license agreement. Check if the user has already
|
* Initialize get device license agreement. Check if the user has already
|
||||||
* agreed
|
* agreed to license agreement
|
||||||
* to license agreement
|
|
||||||
*/
|
*/
|
||||||
private void getLicense() {
|
private void getLicense() {
|
||||||
String isAgreed =
|
String licenseAgreedResponse =
|
||||||
Preference.get(context,
|
Preference.get(context,
|
||||||
getResources().getString(R.string.shared_pref_isagreed));
|
getResources().getString(R.string.shared_pref_isagreed));
|
||||||
String type =
|
String type =
|
||||||
@ -347,9 +338,7 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
|
|||||||
|
|
||||||
// No need to display license for COPE devices
|
// No need to display license for COPE devices
|
||||||
if (type.trim().equals(getResources().getString(R.string.device_enroll_type_byod))) {
|
if (type.trim().equals(getResources().getString(R.string.device_enroll_type_byod))) {
|
||||||
if (isAgreed == null) {
|
if (licenseAgreedResponse == null) {
|
||||||
Map<String, String> requestParams = new HashMap<String, String>();
|
|
||||||
requestParams.put("domain", txtDomain.getText().toString().trim());
|
|
||||||
|
|
||||||
// Get License
|
// Get License
|
||||||
OnCancelListener cancelListener = new OnCancelListener() {
|
OnCancelListener cancelListener = new OnCancelListener() {
|
||||||
@ -361,7 +350,6 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
|
|||||||
getResources().getString(R.string.error_enrollment_failed),
|
getResources().getString(R.string.error_enrollment_failed),
|
||||||
getResources().getString(R.string.button_ok),
|
getResources().getString(R.string.button_ok),
|
||||||
null);
|
null);
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -403,7 +391,7 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
|
|||||||
response =
|
response =
|
||||||
HTTPConnectorUtils.postData(context,
|
HTTPConnectorUtils.postData(context,
|
||||||
CommonUtilities.SERVER_URL +
|
CommonUtilities.SERVER_URL +
|
||||||
CommonUtilities.LICENSE_ENDPOINT,
|
CommonUtilities.LICENSE_ENDPOINT,
|
||||||
null);
|
null);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@ -433,12 +421,11 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
|
|||||||
private void manipulateLicenseResponse(Map<String, String> result) {
|
private void manipulateLicenseResponse(Map<String, String> result) {
|
||||||
String responseStatus;
|
String responseStatus;
|
||||||
CommonDialogUtils.stopProgressDialog(progressDialog);
|
CommonDialogUtils.stopProgressDialog(progressDialog);
|
||||||
String licenseAgreement = "";
|
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
responseStatus = result.get(CommonUtilities.STATUS_KEY);
|
responseStatus = result.get(CommonUtilities.STATUS_KEY);
|
||||||
if (responseStatus.equals(CommonUtilities.REQUEST_SUCCESSFUL)) {
|
if (responseStatus.equals(CommonUtilities.REQUEST_SUCCESSFUL)) {
|
||||||
licenseAgreement = result.get("response");
|
String licenseAgreement = result.get(Constant.RESPONSE);
|
||||||
|
|
||||||
if (licenseAgreement != null) {
|
if (licenseAgreement != null) {
|
||||||
Preference.put(context, getResources().getString(R.string.shared_pref_eula),
|
Preference.put(context, getResources().getString(R.string.shared_pref_eula),
|
||||||
@ -488,7 +475,6 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
|
|||||||
String html = "<html><body>" + message + "</body></html>";
|
String html = "<html><body>" + message + "</body></html>";
|
||||||
String mime = "text/html";
|
String mime = "text/html";
|
||||||
String encoding = "utf-8";
|
String encoding = "utf-8";
|
||||||
web.getSettings().setJavaScriptEnabled(true);
|
|
||||||
web.loadDataWithBaseURL(null, html, mime, encoding, null);
|
web.loadDataWithBaseURL(null, html, mime, encoding, null);
|
||||||
|
|
||||||
Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK);
|
Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK);
|
||||||
@ -545,7 +531,6 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
|
|||||||
editor.putString(getResources().getString(R.string.shared_pref_registered), "0");
|
editor.putString(getResources().getString(R.string.shared_pref_registered), "0");
|
||||||
editor.putString(getResources().getString(R.string.shared_pref_ip), "");
|
editor.putString(getResources().getString(R.string.shared_pref_ip), "");
|
||||||
editor.commit();
|
editor.commit();
|
||||||
// finish();
|
|
||||||
|
|
||||||
Intent intentIP = new Intent(AuthenticationActivity.this, ServerDetails.class);
|
Intent intentIP = new Intent(AuthenticationActivity.this, ServerDetails.class);
|
||||||
intentIP.putExtra(getResources().getString(R.string.intent_extra_from_activity),
|
intentIP.putExtra(getResources().getString(R.string.intent_extra_from_activity),
|
||||||
@ -567,12 +552,6 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
|
|||||||
dialog.cancel();
|
dialog.cancel();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/*
|
|
||||||
* builder1.setNegativeButton("No", new
|
|
||||||
* DialogInterface.OnClickListener() { public void
|
|
||||||
* onClick(DialogInterface dialog, int id) { dialog.cancel(); } });
|
|
||||||
*/
|
|
||||||
|
|
||||||
AlertDialog alert = builder.create();
|
AlertDialog alert = builder.create();
|
||||||
alert.show();
|
alert.show();
|
||||||
}
|
}
|
||||||
@ -588,12 +567,6 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
|
|||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/*
|
|
||||||
* builder1.setNegativeButton("No", new
|
|
||||||
* DialogInterface.OnClickListener() { public void
|
|
||||||
* onClick(DialogInterface dialog, int id) { dialog.cancel(); } });
|
|
||||||
*/
|
|
||||||
|
|
||||||
AlertDialog alert = builder.create();
|
AlertDialog alert = builder.create();
|
||||||
alert.show();
|
alert.show();
|
||||||
}
|
}
|
||||||
@ -611,21 +584,21 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
|
|||||||
String serverURL =
|
String serverURL =
|
||||||
CommonUtilities.SERVER_PROTOCOL + serverIP + ":" +
|
CommonUtilities.SERVER_PROTOCOL + serverIP + ":" +
|
||||||
CommonUtilities.SERVER_PORT + CommonUtilities.OAUTH_ENDPOINT;
|
CommonUtilities.SERVER_PORT + CommonUtilities.OAUTH_ENDPOINT;
|
||||||
if (txtDomain.getText() != null && !txtDomain.getText().toString().trim().equals("")) {
|
if (etDomain.getText() != null && !etDomain.getText().toString().trim().equals("")) {
|
||||||
usernameForRegister =
|
usernameForRegister =
|
||||||
username.getText().toString().trim() + "@" +
|
etUsername.getText().toString().trim() + "@" +
|
||||||
txtDomain.getText().toString().trim();
|
etDomain.getText().toString().trim();
|
||||||
|
|
||||||
IdentityProxy.getInstance().init(clientKey, clientSecret, usernameForRegister,
|
IdentityProxy.getInstance().init(clientKey, clientSecret, usernameForRegister,
|
||||||
password.getText().toString().trim(), serverURL,
|
etPassword.getText().toString().trim(), serverURL,
|
||||||
AuthenticationActivity.this,
|
AuthenticationActivity.this,
|
||||||
this.getApplicationContext());
|
this.getApplicationContext());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
usernameForRegister = username.getText().toString().trim();
|
usernameForRegister = etUsername.getText().toString().trim();
|
||||||
|
|
||||||
IdentityProxy.getInstance().init(clientKey, clientSecret, usernameForRegister,
|
IdentityProxy.getInstance().init(clientKey, clientSecret, usernameForRegister,
|
||||||
password.getText().toString().trim(), serverURL,
|
etPassword.getText().toString().trim(), serverURL,
|
||||||
AuthenticationActivity.this,
|
AuthenticationActivity.this,
|
||||||
this.getApplicationContext());
|
this.getApplicationContext());
|
||||||
}
|
}
|
||||||
@ -635,19 +608,19 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
|
|||||||
|
|
||||||
boolean isReady = false;
|
boolean isReady = false;
|
||||||
|
|
||||||
if (username.getText().toString().length() >= 1 &&
|
if (etUsername.getText().toString().length() >= 1 &&
|
||||||
password.getText().toString().length() >= 1) {
|
etPassword.getText().toString().length() >= 1) {
|
||||||
isReady = true;
|
isReady = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isReady) {
|
if (isReady) {
|
||||||
authenticate.setBackground(getResources().getDrawable(R.drawable.btn_orange));
|
btnRegister.setBackground(getResources().getDrawable(R.drawable.btn_orange));
|
||||||
authenticate.setTextColor(getResources().getColor(R.color.white));
|
btnRegister.setTextColor(getResources().getColor(R.color.white));
|
||||||
authenticate.setEnabled(true);
|
btnRegister.setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
authenticate.setBackground(getResources().getDrawable(R.drawable.btn_grey));
|
btnRegister.setBackground(getResources().getDrawable(R.drawable.btn_grey));
|
||||||
authenticate.setTextColor(getResources().getColor(R.color.black));
|
btnRegister.setTextColor(getResources().getColor(R.color.black));
|
||||||
authenticate.setEnabled(false);
|
btnRegister.setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -699,12 +672,12 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog,
|
||||||
int which) {
|
int which) {
|
||||||
username.setText(CommonUtilities.EMPTY_STRING);
|
etUsername.setText(CommonUtilities.EMPTY_STRING);
|
||||||
password.setText(CommonUtilities.EMPTY_STRING);
|
etPassword.setText(CommonUtilities.EMPTY_STRING);
|
||||||
txtDomain.setText(CommonUtilities.EMPTY_STRING);
|
etDomain.setText(CommonUtilities.EMPTY_STRING);
|
||||||
authenticate.setEnabled(false);
|
btnRegister.setEnabled(false);
|
||||||
authenticate.setBackground(getResources().getDrawable(R.drawable.btn_grey));
|
btnRegister.setBackground(getResources().getDrawable(R.drawable.btn_grey));
|
||||||
authenticate.setTextColor(getResources().getColor(R.color.black));
|
btnRegister.setTextColor(getResources().getColor(R.color.black));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -766,7 +739,7 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
|
|||||||
editor.commit();
|
editor.commit();
|
||||||
|
|
||||||
Map<String, String> requestParams = new HashMap<String, String>();
|
Map<String, String> requestParams = new HashMap<String, String>();
|
||||||
requestParams.put("domain", txtDomain.getText().toString().trim());
|
requestParams.put("domain", etDomain.getText().toString().trim());
|
||||||
// Check network connection availability before calling the API.
|
// Check network connection availability before calling the API.
|
||||||
if (PhoneState.isNetworkAvailable(context)) {
|
if (PhoneState.isNetworkAvailable(context)) {
|
||||||
// Call get sender ID API.
|
// Call get sender ID API.
|
||||||
@ -871,7 +844,7 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
|
|||||||
responseStatus = result.get(CommonUtilities.STATUS_KEY);
|
responseStatus = result.get(CommonUtilities.STATUS_KEY);
|
||||||
if (responseStatus.equals(CommonUtilities.REQUEST_SUCCESSFUL)) {
|
if (responseStatus.equals(CommonUtilities.REQUEST_SUCCESSFUL)) {
|
||||||
try {
|
try {
|
||||||
response = new JSONObject(result.get("response"));
|
response = new JSONObject(result.get(Constant.RESPONSE));
|
||||||
senderId = response.getString("sender_id");
|
senderId = response.getString("sender_id");
|
||||||
mode = response.getString("notifier");
|
mode = response.getString("notifier");
|
||||||
interval = (float) Float.parseFloat(response.getString("notifierInterval"));
|
interval = (float) Float.parseFloat(response.getString("notifierInterval"));
|
||||||
|
|||||||
@ -40,12 +40,12 @@ import org.wso2.cdm.agent.utils.Responce;
|
|||||||
*/
|
*/
|
||||||
public class ServerDetails extends Activity {
|
public class ServerDetails extends Activity {
|
||||||
|
|
||||||
TextView serverIP;
|
TextView evServerIP;
|
||||||
Button startRegistration;
|
Button btnStartRegistration;
|
||||||
Context context;
|
Context context;
|
||||||
DialogInterface.OnClickListener dialogClickListener;
|
DialogInterface.OnClickListener dialogClickListener;
|
||||||
DeviceInfo info;
|
DeviceInfo info;
|
||||||
TextView severAddressLabel;
|
TextView tvSeverAddress;
|
||||||
|
|
||||||
String senderID = null;
|
String senderID = null;
|
||||||
ProgressDialog progressDialog;
|
ProgressDialog progressDialog;
|
||||||
@ -62,49 +62,51 @@ public class ServerDetails extends Activity {
|
|||||||
setContentView(R.layout.activity_settings);
|
setContentView(R.layout.activity_settings);
|
||||||
context = ServerDetails.this;
|
context = ServerDetails.this;
|
||||||
info = new DeviceInfo(ServerDetails.this);
|
info = new DeviceInfo(ServerDetails.this);
|
||||||
serverIP = (TextView) findViewById(R.id.etServerIP);
|
evServerIP = (TextView) findViewById(R.id.evServerIP);
|
||||||
severAddressLabel = (TextView) findViewById(R.id.severAddressLabel);
|
tvSeverAddress = (TextView) findViewById(R.id.tvSeverAddress);
|
||||||
startRegistration = (Button) findViewById(R.id.startRegistration);
|
btnStartRegistration = (Button) findViewById(R.id.btnStartRegistration);
|
||||||
|
|
||||||
// Checking if the device meets minimum requirements
|
// Checking if the device meets minimum requirements
|
||||||
Responce compatibility = info.isCompatible();
|
Responce compatibility = info.isCompatible();
|
||||||
if (!compatibility.getCode()) {
|
if (!compatibility.getCode()) {
|
||||||
startRegistration.setVisibility(View.GONE);
|
btnStartRegistration.setVisibility(View.GONE);
|
||||||
severAddressLabel.setVisibility(View.GONE);
|
tvSeverAddress.setVisibility(View.GONE);
|
||||||
serverIP.setVisibility(View.GONE);
|
evServerIP.setVisibility(View.GONE);
|
||||||
alertDialog =
|
alertDialog =
|
||||||
CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(context.getApplicationContext(),
|
CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(context,
|
||||||
getResources().getString(R.string.error_authorization_failed),
|
getResources().getString(R.string.error_authorization_failed),
|
||||||
getResources().getString(compatibility.getDescriptionResourceID()),
|
getResources().getString(compatibility.getDescriptionResourceID()),
|
||||||
getResources().getString(R.string.button_ok),
|
getResources().getString(R.string.button_ok),
|
||||||
onRootedClickListner);
|
onRootedClickListner);
|
||||||
} else {
|
} else {
|
||||||
startRegistration.setVisibility(View.VISIBLE);
|
btnStartRegistration.setVisibility(View.VISIBLE);
|
||||||
serverIP.setVisibility(View.VISIBLE);
|
evServerIP.setVisibility(View.VISIBLE);
|
||||||
String ipSaved =
|
String ipSaved =
|
||||||
Preference.get(context.getApplicationContext(),
|
Preference.get(context.getApplicationContext(),
|
||||||
getResources().getString(R.string.shared_pref_ip));
|
getResources().getString(R.string.shared_pref_ip));
|
||||||
regId = Preference.get(context.getApplicationContext().getApplicationContext(), getResources().getString(R.string.shared_pref_regId));
|
regId = Preference.get(context.getApplicationContext(), getResources().getString(R.string.shared_pref_regId));
|
||||||
|
|
||||||
//heck if we have the IP saved previously.
|
//check if we have the IP saved previously.
|
||||||
if (ipSaved != null) {
|
if (ipSaved != null) {
|
||||||
serverIP.setText(ipSaved);
|
evServerIP.setText(ipSaved);
|
||||||
CommonUtilities.setServerURL(ipSaved);
|
CommonUtilities.setServerURL(ipSaved);
|
||||||
startAuthenticationActivity();
|
startAuthenticationActivity();
|
||||||
} else {
|
} else {
|
||||||
serverIP.setText(CommonUtilities.SERVER_IP);
|
evServerIP.setText(CommonUtilities.SERVER_IP);
|
||||||
}
|
}
|
||||||
|
|
||||||
// on click handler for start registration
|
// on click handler for start registration
|
||||||
startRegistration.setOnClickListener(new OnClickListener() {
|
btnStartRegistration.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(ServerDetails.this);
|
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(ServerDetails.this);
|
||||||
builder.setMessage(getResources().getString(R.string.dialog_init_confirmation) +
|
StringBuilder messageBuilder = new StringBuilder();
|
||||||
" " +
|
messageBuilder.append(getResources().getString(R.string.dialog_init_confirmation));
|
||||||
serverIP.getText().toString() +
|
messageBuilder.append(" ");
|
||||||
" " +
|
messageBuilder.append(evServerIP.getText().toString());
|
||||||
getResources().getString(R.string.dialog_init_end_general))
|
messageBuilder.append(" ");
|
||||||
|
messageBuilder.append(getResources().getString(R.string.dialog_init_end_general));
|
||||||
|
alertBuilder.setMessage(messageBuilder.toString())
|
||||||
.setPositiveButton(getResources().getString(R.string.yes),
|
.setPositiveButton(getResources().getString(R.string.yes),
|
||||||
dialogClickListener)
|
dialogClickListener)
|
||||||
.setNegativeButton(getResources().getString(R.string.no),
|
.setNegativeButton(getResources().getString(R.string.no),
|
||||||
@ -117,11 +119,11 @@ public class ServerDetails extends Activity {
|
|||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
switch (which) {
|
switch (which) {
|
||||||
case DialogInterface.BUTTON_POSITIVE:
|
case DialogInterface.BUTTON_POSITIVE:
|
||||||
if (!serverIP.getText().toString().trim().equals("")) {
|
if (!evServerIP.getText().toString().trim().equals("")) {
|
||||||
CommonUtilities.setServerURL(serverIP.getText().toString().trim());
|
CommonUtilities.setServerURL(evServerIP.getText().toString().trim());
|
||||||
Preference.put(context.getApplicationContext(),
|
Preference.put(context.getApplicationContext(),
|
||||||
getResources().getString(R.string.shared_pref_ip),
|
getResources().getString(R.string.shared_pref_ip),
|
||||||
serverIP.getText().toString().trim());
|
evServerIP.getText().toString().trim());
|
||||||
startAuthenticationActivity();
|
startAuthenticationActivity();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -148,6 +150,9 @@ public class ServerDetails extends Activity {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called to open AuthenticationActivity.
|
||||||
|
*/
|
||||||
private void startAuthenticationActivity() {
|
private void startAuthenticationActivity() {
|
||||||
Intent intent = new Intent(ServerDetails.this, AuthenticationActivity.class);
|
Intent intent = new Intent(ServerDetails.this, AuthenticationActivity.class);
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
@ -161,10 +166,13 @@ public class ServerDetails extends Activity {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
//Avoiding memory leaks by destroying context object
|
|
||||||
context = null;
|
context = null;
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Old API manager communication code.
|
// Old API manager communication code.
|
||||||
//
|
//
|
||||||
|
|||||||
@ -39,112 +39,113 @@ import javax.ws.rs.core.Response;
|
|||||||
@Consumes({ "application/json", "application/xml" })
|
@Consumes({ "application/json", "application/xml" })
|
||||||
public class Enrollment {
|
public class Enrollment {
|
||||||
|
|
||||||
private static Log log = LogFactory.getLog(Enrollment.class);
|
private static Log log = LogFactory.getLog(Enrollment.class);
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
public Message enrollDevice(org.wso2.carbon.device.mgt.common.Device device) throws AndroidAgentException {
|
public Message enrollDevice(org.wso2.carbon.device.mgt.common.Device device)
|
||||||
|
throws AndroidAgentException {
|
||||||
|
|
||||||
Message responseMsg = new Message();
|
Message responseMsg = new Message();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||||
AndroidAPIUtils.getDeviceManagementService().enrollDevice(device);
|
AndroidAPIUtils.getDeviceManagementService().enrollDevice(device);
|
||||||
Response.status(Response.Status.CREATED);
|
Response.status(Response.Status.CREATED);
|
||||||
responseMsg.setResponseMessage("Device enrollment succeeded");
|
responseMsg.setResponseMessage("Device enrollment succeeded");
|
||||||
return responseMsg;
|
return responseMsg;
|
||||||
} catch (DeviceManagementServiceException deviceServiceMgtEx) {
|
} catch (DeviceManagementServiceException deviceServiceMgtEx) {
|
||||||
String errorMsg = "Device management service error";
|
String errorMsg = "Device management service error";
|
||||||
log.error(errorMsg, deviceServiceMgtEx);
|
log.error(errorMsg, deviceServiceMgtEx);
|
||||||
throw new AndroidAgentException(errorMsg, deviceServiceMgtEx);
|
throw new AndroidAgentException(errorMsg, deviceServiceMgtEx);
|
||||||
} catch (DeviceManagementException deviceMgtEx) {
|
} catch (DeviceManagementException deviceMgtEx) {
|
||||||
String errorMsg = "Error occurred while enrolling the device";
|
String errorMsg = "Error occurred while enrolling the device";
|
||||||
log.error(errorMsg, deviceMgtEx);
|
log.error(errorMsg, deviceMgtEx);
|
||||||
throw new AndroidAgentException(errorMsg, deviceMgtEx);
|
throw new AndroidAgentException(errorMsg, deviceMgtEx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
public Message isEnrolled(@PathParam("id") String id) throws AndroidAgentException {
|
public Message isEnrolled(@PathParam("id") String id) throws AndroidAgentException {
|
||||||
|
|
||||||
boolean result;
|
boolean result;
|
||||||
Message responseMsg = new Message();
|
Message responseMsg = new Message();
|
||||||
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
result = AndroidAPIUtils.getDeviceManagementService().isEnrolled(deviceIdentifier);
|
result = AndroidAPIUtils.getDeviceManagementService().isEnrolled(deviceIdentifier);
|
||||||
if (result) {
|
if (result) {
|
||||||
responseMsg.setResponseMessage("Device has already enrolled");
|
responseMsg.setResponseMessage("Device has already enrolled");
|
||||||
} else {
|
} else {
|
||||||
Response.status(Response.Status.NOT_FOUND);
|
Response.status(Response.Status.NOT_FOUND);
|
||||||
responseMsg.setResponseMessage("Device not found");
|
responseMsg.setResponseMessage("Device not found");
|
||||||
}
|
}
|
||||||
return responseMsg;
|
return responseMsg;
|
||||||
} catch (DeviceManagementServiceException deviceServiceMgtEx) {
|
} catch (DeviceManagementServiceException deviceServiceMgtEx) {
|
||||||
String errorMsg = "Device management service error";
|
String errorMsg = "Device management service error";
|
||||||
log.error(errorMsg, deviceServiceMgtEx);
|
log.error(errorMsg, deviceServiceMgtEx);
|
||||||
throw new AndroidAgentException(errorMsg, deviceServiceMgtEx);
|
throw new AndroidAgentException(errorMsg, deviceServiceMgtEx);
|
||||||
} catch (DeviceManagementException deviceMgtEx) {
|
} catch (DeviceManagementException deviceMgtEx) {
|
||||||
String errorMsg = "Error occurred while enrollment of the device.";
|
String errorMsg = "Error occurred while enrollment of the device.";
|
||||||
log.error(errorMsg, deviceMgtEx);
|
log.error(errorMsg, deviceMgtEx);
|
||||||
throw new AndroidAgentException(errorMsg, deviceMgtEx);
|
throw new AndroidAgentException(errorMsg, deviceMgtEx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
public Message modifyEnrollment(@PathParam("id") String id, org.wso2.carbon.device.mgt.common.Device device)
|
public Message modifyEnrollment(@PathParam("id") String id,
|
||||||
throws AndroidAgentException {
|
org.wso2.carbon.device.mgt.common.Device device)
|
||||||
|
throws AndroidAgentException {
|
||||||
|
|
||||||
boolean result;
|
boolean result;
|
||||||
Message responseMsg = new Message();
|
Message responseMsg = new Message();
|
||||||
try {
|
try {
|
||||||
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||||
result = AndroidAPIUtils.getDeviceManagementService().modifyEnrollment(device);
|
result = AndroidAPIUtils.getDeviceManagementService().modifyEnrollment(device);
|
||||||
if (result) {
|
if (result) {
|
||||||
responseMsg.setResponseMessage("Device enrollment has updated successfully");
|
responseMsg.setResponseMessage("Device enrollment has updated successfully");
|
||||||
Response.status(Response.Status.ACCEPTED);
|
Response.status(Response.Status.ACCEPTED);
|
||||||
} else {
|
} else {
|
||||||
responseMsg.setResponseMessage("Device not found for enrollment");
|
responseMsg.setResponseMessage("Device not found for enrollment");
|
||||||
Response.status(Response.Status.NOT_MODIFIED);
|
Response.status(Response.Status.NOT_MODIFIED);
|
||||||
}
|
}
|
||||||
return responseMsg;
|
return responseMsg;
|
||||||
} catch (DeviceManagementServiceException deviceServiceMgtEx) {
|
} catch (DeviceManagementServiceException deviceServiceMgtEx) {
|
||||||
String errorMsg = "Device management service error";
|
String errorMsg = "Device management service error";
|
||||||
log.error(errorMsg, deviceServiceMgtEx);
|
log.error(errorMsg, deviceServiceMgtEx);
|
||||||
throw new AndroidAgentException(errorMsg, deviceServiceMgtEx);
|
throw new AndroidAgentException(errorMsg, deviceServiceMgtEx);
|
||||||
} catch (DeviceManagementException deviceMgtEx) {
|
} catch (DeviceManagementException deviceMgtEx) {
|
||||||
String errorMsg = "Error occurred while modifying enrollment of the device";
|
String errorMsg = "Error occurred while modifying enrollment of the device";
|
||||||
log.error(errorMsg, deviceMgtEx);
|
log.error(errorMsg, deviceMgtEx);
|
||||||
throw new AndroidAgentException(errorMsg, deviceMgtEx);
|
throw new AndroidAgentException(errorMsg, deviceMgtEx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
public Message disEnrollDevice(@PathParam("id") String id) throws AndroidAgentException {
|
public Message disEnrollDevice(@PathParam("id") String id) throws AndroidAgentException {
|
||||||
|
Message responseMsg = new Message();
|
||||||
|
boolean result;
|
||||||
|
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
||||||
|
|
||||||
Message responseMsg = new Message();
|
try {
|
||||||
boolean result;
|
result = AndroidAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier);
|
||||||
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
if (result) {
|
||||||
|
responseMsg.setResponseMessage("Device has removed successfully");
|
||||||
try {
|
} else {
|
||||||
result = AndroidAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier);
|
responseMsg.setResponseMessage("Device not found");
|
||||||
if (result) {
|
Response.status(Response.Status.NOT_FOUND);
|
||||||
responseMsg.setResponseMessage("Device has removed successfully");
|
}
|
||||||
} else {
|
return responseMsg;
|
||||||
responseMsg.setResponseMessage("Device not found");
|
} catch (DeviceManagementServiceException deviceServiceMgtEx) {
|
||||||
Response.status(Response.Status.NOT_FOUND);
|
String errorMsg = "Device management service error";
|
||||||
}
|
log.error(errorMsg, deviceServiceMgtEx);
|
||||||
return responseMsg;
|
throw new AndroidAgentException(errorMsg, deviceServiceMgtEx);
|
||||||
} catch (DeviceManagementServiceException deviceServiceMgtEx) {
|
} catch (DeviceManagementException deviceMgtEx) {
|
||||||
String errorMsg = "Device management service error";
|
String errorMsg = "Error occurred while dis enrolling the device";
|
||||||
log.error(errorMsg, deviceServiceMgtEx);
|
log.error(errorMsg, deviceMgtEx);
|
||||||
throw new AndroidAgentException(errorMsg, deviceServiceMgtEx);
|
throw new AndroidAgentException(errorMsg, deviceMgtEx);
|
||||||
} catch (DeviceManagementException deviceMgtEx) {
|
}
|
||||||
String errorMsg = "Error occurred while dis enrolling the device";
|
}
|
||||||
log.error(errorMsg, deviceMgtEx);
|
|
||||||
throw new AndroidAgentException(errorMsg, deviceMgtEx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,9 +23,9 @@
|
|||||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||||
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
|
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
|
||||||
|
|
||||||
<jaxrs:server id="customerService" address="/register">
|
<jaxrs:server id="operationService" address="/operations">
|
||||||
<jaxrs:serviceBeans>
|
<jaxrs:serviceBeans>
|
||||||
<ref bean="deviceMgtServiceBean"/>
|
<ref bean="operationServiceBean"/>
|
||||||
</jaxrs:serviceBeans>
|
</jaxrs:serviceBeans>
|
||||||
<jaxrs:providers>
|
<jaxrs:providers>
|
||||||
<ref bean="jsonProvider"/>
|
<ref bean="jsonProvider"/>
|
||||||
@ -53,6 +53,7 @@
|
|||||||
|
|
||||||
<bean id="deviceMgtServiceBean" class="org.wso2.cdmserver.mobileservices.android.Device"/>
|
<bean id="deviceMgtServiceBean" class="org.wso2.cdmserver.mobileservices.android.Device"/>
|
||||||
<bean id="enrollmentServiceBean" class="org.wso2.cdmserver.mobileservices.android.Enrollment"/>
|
<bean id="enrollmentServiceBean" class="org.wso2.cdmserver.mobileservices.android.Enrollment"/>
|
||||||
|
<bean id="operationServiceBean" class="org.wso2.cdmserver.mobileservices.android.Operation"/>
|
||||||
<bean id="jsonProvider" class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/>
|
<bean id="jsonProvider" class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/>
|
||||||
<bean id="errorHandler" class="org.wso2.cdmserver.mobileservices.android.common.ErrorHandler"/>
|
<bean id="errorHandler" class="org.wso2.cdmserver.mobileservices.android.common.ErrorHandler"/>
|
||||||
</beans>
|
</beans>
|
||||||
|
|||||||
@ -181,6 +181,104 @@
|
|||||||
<artifactId>bcprov-jdk15on</artifactId>
|
<artifactId>bcprov-jdk15on</artifactId>
|
||||||
<version>1.49</version>
|
<version>1.49</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.ws.commons.axiom</groupId>
|
||||||
|
<artifactId>axiom-api</artifactId>
|
||||||
|
<version>1.2.14</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.ws.commons.axiom</groupId>
|
||||||
|
<artifactId>axiom-impl</artifactId>
|
||||||
|
<version>1.2.14</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.cxf</groupId>
|
||||||
|
<artifactId>cxf-rt-frontend-jaxws</artifactId>
|
||||||
|
<version>2.6.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.cxf</groupId>
|
||||||
|
<artifactId>cxf-rt-bindings-soap</artifactId>
|
||||||
|
<version>2.6.1</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.cxf</groupId>
|
||||||
|
<artifactId>cxf-rt-transports-http</artifactId>
|
||||||
|
<version>2.6.1</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.cxf</groupId>
|
||||||
|
<artifactId>cxf-rt-rs-extension-providers</artifactId>
|
||||||
|
<version>2.6.1</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.cxf</groupId>
|
||||||
|
<artifactId>cxf-rt-ws-security</artifactId>
|
||||||
|
<version>2.6.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.cxf</groupId>
|
||||||
|
<artifactId>cxf-rt-transports-http</artifactId>
|
||||||
|
<version>2.6.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.wss4j</groupId>
|
||||||
|
<artifactId>wss4j-ws-security-common</artifactId>
|
||||||
|
<version>2.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-web</artifactId>
|
||||||
|
<version>3.0.5.RELEASE</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-context</artifactId>
|
||||||
|
<version>3.0.5.RELEASE</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sun.xml.messaging.saaj</groupId>
|
||||||
|
<artifactId>saaj-impl</artifactId>
|
||||||
|
<version>1.3.18</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sun.xml.messaging.saaj</groupId>
|
||||||
|
<artifactId>saaj-impl</artifactId>
|
||||||
|
<version>1.3.18</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bouncycastle</groupId>
|
||||||
|
<artifactId>bcpkix-jdk15on</artifactId>
|
||||||
|
<version>1.49</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bouncycastle</groupId>
|
||||||
|
<artifactId>bcprov-jdk15on</artifactId>
|
||||||
|
<version>1.49</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.codehaus.plexus</groupId>
|
||||||
|
<artifactId>plexus-utils</artifactId>
|
||||||
|
<version>3.0.21</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.madgag.spongycastle</groupId>
|
||||||
|
<artifactId>pkix</artifactId>
|
||||||
|
<version>1.51.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.madgag.spongycastle</groupId>
|
||||||
|
<artifactId>prov</artifactId>
|
||||||
|
<version>1.51.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.madgag.spongycastle</groupId>
|
||||||
|
<artifactId>core</artifactId>
|
||||||
|
<version>1.51.0.0</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<cxf.version>2.6.1</cxf.version>
|
<cxf.version>2.6.1</cxf.version>
|
||||||
|
|||||||
@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2014, 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 cdm.api.windows;
|
|
||||||
|
|
||||||
import javax.ws.rs.*;
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
@Path("/EnrollmentServer")
|
|
||||||
public interface DiscoveryService {
|
|
||||||
|
|
||||||
@Path("/Discovery.svc")
|
|
||||||
@POST
|
|
||||||
@Consumes({ "application/soap+xml;charset=utf-8", "application/xml" })
|
|
||||||
@Produces("application/soap+xml;charset=utf-8")
|
|
||||||
Response getDiscoveryResponse(
|
|
||||||
InputStream discoveryRequest);
|
|
||||||
|
|
||||||
@Path("/Discovery.svc")
|
|
||||||
@GET
|
|
||||||
@Consumes("text/html")
|
|
||||||
@Produces("text/html")
|
|
||||||
Response getDiscoveryOKRequest();
|
|
||||||
|
|
||||||
@Path("/Discovery.svc")
|
|
||||||
@GET
|
|
||||||
@Consumes({ "application/soap+xml;charset=utf-8", "application/xml" })
|
|
||||||
@Produces("text/html")
|
|
||||||
Response getDiscoveryOKRequestWithBody(InputStream discoveryRequest);
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2014, 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 cdm.api.windows;
|
|
||||||
|
|
||||||
import javax.swing.text.Document;
|
|
||||||
import javax.ws.rs.Consumes;
|
|
||||||
import javax.ws.rs.POST;
|
|
||||||
import javax.ws.rs.Path;
|
|
||||||
import javax.ws.rs.Produces;
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
|
|
||||||
@Path("/ENROLLMENTSERVER")
|
|
||||||
public interface EnrolmentService {
|
|
||||||
|
|
||||||
@Path("/PolicyEnrollmentWebservice.svc")
|
|
||||||
@POST
|
|
||||||
@Consumes("application/soap+xml;charset=utf-8")
|
|
||||||
@Produces("application/soap+xml;charset=utf-8")
|
|
||||||
Response getPolicies(Document request);
|
|
||||||
|
|
||||||
@Path("/DeviceEnrollmentWebservice.svc")
|
|
||||||
@POST
|
|
||||||
@Consumes("application/soap+xml;charset=utf-8")
|
|
||||||
@Produces("application/soap+xml;charset=utf-8")
|
|
||||||
Response enrollUser(Document request);
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,72 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2014, 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 cdm.api.windows.impl;
|
|
||||||
|
|
||||||
import cdm.api.windows.DiscoveryService;
|
|
||||||
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
public class DiscoveryServiceImpl implements DiscoveryService {
|
|
||||||
|
|
||||||
private Logger LOGGER = Logger.getLogger(DiscoveryServiceImpl.class);
|
|
||||||
|
|
||||||
public Response getDiscoveryResponse(InputStream discoveryRequest) {
|
|
||||||
LOGGER.info("Received Discovery Service POST Request [{}]");
|
|
||||||
|
|
||||||
String response = null;
|
|
||||||
File file = null;
|
|
||||||
FileInputStream fis = null;
|
|
||||||
byte[] data = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
file = new File("./conf/discover-service.xml");
|
|
||||||
fis = new FileInputStream(file);
|
|
||||||
data = new byte[(int) file.length()];
|
|
||||||
fis.read(data);
|
|
||||||
fis.close();
|
|
||||||
response = new String(data, "UTF-8");
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
LOGGER.error("An Unexpected Error has occurred while processing the request ", e);
|
|
||||||
}
|
|
||||||
LOGGER.info("Sending Discovery Response");
|
|
||||||
|
|
||||||
return Response.ok().entity(response).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Response getDiscoveryOKRequest() {
|
|
||||||
LOGGER.info("Received a GET Request without body");
|
|
||||||
return Response.ok().build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Response getDiscoveryOKRequestWithBody(InputStream discoveryRequest) {
|
|
||||||
LOGGER.info("Received a GET Request with body [{}]");
|
|
||||||
return Response.ok().build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,305 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2014, 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 cdm.api.windows.impl;
|
|
||||||
|
|
||||||
import cdm.api.windows.EnrolmentService;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
|
||||||
import org.bouncycastle.pkcs.PKCS10CertificationRequest;
|
|
||||||
import org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequest;
|
|
||||||
import org.w3c.dom.NamedNodeMap;
|
|
||||||
import org.w3c.dom.Node;
|
|
||||||
import org.w3c.dom.NodeList;
|
|
||||||
import sun.misc.BASE64Decoder;
|
|
||||||
import sun.misc.BASE64Encoder;
|
|
||||||
import javax.swing.text.Document;
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
import javax.xml.namespace.NamespaceContext;
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
|
||||||
import javax.xml.transform.Transformer;
|
|
||||||
import javax.xml.transform.TransformerFactory;
|
|
||||||
import javax.xml.transform.dom.DOMSource;
|
|
||||||
import javax.xml.transform.stream.StreamResult;
|
|
||||||
import javax.xml.xpath.XPath;
|
|
||||||
import javax.xml.xpath.XPathConstants;
|
|
||||||
import javax.xml.xpath.XPathFactory;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.security.KeyFactory;
|
|
||||||
import java.security.PrivateKey;
|
|
||||||
import java.security.Security;
|
|
||||||
import java.security.cert.CertificateFactory;
|
|
||||||
import java.security.cert.X509Certificate;
|
|
||||||
import java.security.spec.PKCS8EncodedKeySpec;
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
import cdm.api.windows.util.CertificateSigningService;
|
|
||||||
|
|
||||||
public class EnrolmentServiceImpl implements EnrolmentService {
|
|
||||||
|
|
||||||
private Logger LOGGER = Logger.getLogger(EnrolmentServiceImpl.class);
|
|
||||||
|
|
||||||
static {
|
|
||||||
Security.addProvider(new BouncyCastleProvider());
|
|
||||||
}
|
|
||||||
|
|
||||||
private String enrollmentResponseFile;
|
|
||||||
|
|
||||||
private String wapProvisioningXmlFile;
|
|
||||||
|
|
||||||
private String privatePemKeyFilePath;
|
|
||||||
|
|
||||||
private String caCertificateFilePath;
|
|
||||||
|
|
||||||
PrivateKey privateKey;
|
|
||||||
|
|
||||||
X509Certificate rooCACertificate;
|
|
||||||
|
|
||||||
public void init() {
|
|
||||||
|
|
||||||
try {
|
|
||||||
FileInputStream in = new FileInputStream(privatePemKeyFilePath);
|
|
||||||
byte[] keyBytes = new byte[in.available()];
|
|
||||||
in.read(keyBytes);
|
|
||||||
in.close();
|
|
||||||
|
|
||||||
String key = new String(keyBytes, "UTF-8");
|
|
||||||
key = key.replaceAll(
|
|
||||||
"(-+BEGIN RSA PRIVATE KEY-+\\r?\\n|-+END RSA PRIVATE KEY-+\\r?\\n?)", "");
|
|
||||||
|
|
||||||
// don't use this for real projects!
|
|
||||||
BASE64Decoder decoder = new BASE64Decoder();
|
|
||||||
keyBytes = decoder.decodeBuffer(key);
|
|
||||||
|
|
||||||
// generate private key
|
|
||||||
|
|
||||||
PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes);
|
|
||||||
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
|
||||||
|
|
||||||
privateKey = keyFactory.generatePrivate(spec);
|
|
||||||
|
|
||||||
LOGGER.info("Private Key Algorithm : " + privateKey.getAlgorithm());
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOGGER.error("An unexpected Error has occurred while reading CA Private Key, ", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
FileInputStream fr = new FileInputStream(caCertificateFilePath);
|
|
||||||
CertificateFactory cf = CertificateFactory.getInstance("X509");
|
|
||||||
rooCACertificate = (X509Certificate) cf.generateCertificate(fr);
|
|
||||||
|
|
||||||
rooCACertificate.verify(rooCACertificate.getPublicKey());
|
|
||||||
|
|
||||||
LOGGER.info("CA Certificate Expiration Date : " + rooCACertificate.getNotAfter());
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOGGER.error("An unexpected Error has occurred while reading CA Root Certificate, ", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*try {
|
|
||||||
KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA");
|
|
||||||
gen.initialize(2048);
|
|
||||||
key = gen.generateKeyPair();
|
|
||||||
PrivateKey privateKey = key.getPrivate();
|
|
||||||
PublicKey publicKey = key.getPublic();
|
|
||||||
|
|
||||||
|
|
||||||
*//**
|
|
||||||
* Following details need to be provided
|
|
||||||
*
|
|
||||||
* Serial number
|
|
||||||
* Signature algorithm
|
|
||||||
* Issuer Name.
|
|
||||||
* Subject Name -- or a Subject Alternative Name (SAN).
|
|
||||||
* Date range (not before, not after).
|
|
||||||
* Subject Public Key.
|
|
||||||
*//*
|
|
||||||
|
|
||||||
X509V3CertificateGenerator v3CertGen = new X509V3CertificateGenerator();
|
|
||||||
v3CertGen.setSerialNumber(BigInteger.valueOf(new SecureRandom().nextInt(Integer.MAX_VALUE)));
|
|
||||||
v3CertGen.setIssuerDN(new X509Principal("CN=wso2.com"));
|
|
||||||
//v3CertGen.setIssuerDN(new X509Principal("CN=wso2.com, OU=Mobile, O=wso2 L=Colombo, C=LK"));
|
|
||||||
v3CertGen.setNotBefore(new Date(System.currentTimeMillis() - 1000L * 60 * 60 * 24 * 30));
|
|
||||||
v3CertGen.setNotAfter(new Date(System.currentTimeMillis() + (1000L * 60 * 60 * 24 * 365*10)));
|
|
||||||
v3CertGen.setSubjectDN(new X509Principal("CN=wso2.com"));
|
|
||||||
v3CertGen.setPublicKey(publicKey);
|
|
||||||
v3CertGen.setSignatureAlgorithm("SHA1withRSA");
|
|
||||||
|
|
||||||
rooCACertificate = v3CertGen.generateX509Certificate(privateKey);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
public Response getPolicies(Document request) {
|
|
||||||
LOGGER.info("Received Get Policies Request");
|
|
||||||
|
|
||||||
String response = null;
|
|
||||||
File file = null;
|
|
||||||
FileInputStream fis = null;
|
|
||||||
byte[] data = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
file = new File("./conf/policy-service.xml");
|
|
||||||
fis = new FileInputStream(file);
|
|
||||||
data = new byte[(int) file.length()];
|
|
||||||
fis.read(data);
|
|
||||||
fis.close();
|
|
||||||
response = new String(data, "UTF-8");
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
LOGGER.error("An Unexpected Error has occurred while processing the request ", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
LOGGER.info("Sending Get Policy Response");
|
|
||||||
return Response.ok().entity(response).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Response enrollUser(Document request) {
|
|
||||||
LOGGER.info("Received User Enrollment Request");
|
|
||||||
|
|
||||||
XPath xPath = XPathFactory.newInstance().newXPath();
|
|
||||||
xPath.setNamespaceContext(new MyNamespaceContext());
|
|
||||||
String response = null;
|
|
||||||
|
|
||||||
DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
|
|
||||||
|
|
||||||
try {
|
|
||||||
NodeList nl = (NodeList) xPath.evaluate(
|
|
||||||
"/s:Envelope/s:Body/wst:RequestSecurityToken/wsse:BinarySecurityToken", request,
|
|
||||||
XPathConstants.NODESET);
|
|
||||||
Node node = nl.item(0);
|
|
||||||
String certificateDataString = node.getTextContent();
|
|
||||||
byte[] derByteArray =
|
|
||||||
javax.xml.bind.DatatypeConverter.parseBase64Binary(certificateDataString);
|
|
||||||
|
|
||||||
PKCS10CertificationRequest certificationRequest =
|
|
||||||
new PKCS10CertificationRequest(derByteArray);
|
|
||||||
JcaPKCS10CertificationRequest csrReq =
|
|
||||||
new JcaPKCS10CertificationRequest(certificationRequest);
|
|
||||||
|
|
||||||
LOGGER.info("Public Key of CSR : " + csrReq.getPublicKey());
|
|
||||||
|
|
||||||
X509Certificate signedCert =
|
|
||||||
CertificateSigningService.signCSR(csrReq, privateKey, rooCACertificate);
|
|
||||||
|
|
||||||
LOGGER.info("Verifying Signed Certificate with CSR's public key : " +
|
|
||||||
signedCert.getPublicKey());
|
|
||||||
|
|
||||||
BASE64Encoder base64Encoder = new BASE64Encoder();
|
|
||||||
String rootCertEncodedString = base64Encoder.encode(rooCACertificate.getEncoded());
|
|
||||||
String signedCertEncoded = base64Encoder.encode(signedCert.getEncoded());
|
|
||||||
|
|
||||||
DocumentBuilder builder = domFactory.newDocumentBuilder();
|
|
||||||
org.w3c.dom.Document dDoc = builder.parse(wapProvisioningXmlFile);
|
|
||||||
|
|
||||||
NodeList wapParm = dDoc.getElementsByTagName("parm");
|
|
||||||
|
|
||||||
NamedNodeMap rootCertAttributes = wapParm.item(0).getAttributes();
|
|
||||||
Node b64Encoded = rootCertAttributes.getNamedItem("value");
|
|
||||||
b64Encoded.setTextContent(rootCertEncodedString);
|
|
||||||
|
|
||||||
NamedNodeMap clientCertAttributes = wapParm.item(1).getAttributes();
|
|
||||||
Node b64CliendEncoded = clientCertAttributes.getNamedItem("value");
|
|
||||||
b64CliendEncoded.setTextContent(signedCertEncoded);
|
|
||||||
|
|
||||||
String wapProvisioning = convertDocumentToString(dDoc);
|
|
||||||
String encodedWap = base64Encoder.encode(wapProvisioning.getBytes());
|
|
||||||
|
|
||||||
org.w3c.dom.Document responseXml = builder.parse(enrollmentResponseFile);
|
|
||||||
NodeList token = responseXml.getElementsByTagName("BinarySecurityToken");
|
|
||||||
|
|
||||||
Node firstToken = token.item(0);
|
|
||||||
firstToken.setTextContent(encodedWap);
|
|
||||||
|
|
||||||
response = convertDocumentToString(responseXml);
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOGGER.error("An Unexpected Error has occurred while processing the request ", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
LOGGER.info("Sending User Enrollment Response");
|
|
||||||
return Response.ok().entity(response).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String convertDocumentToString(org.w3c.dom.Document document) throws Exception {
|
|
||||||
DOMSource domSource = new DOMSource(document);
|
|
||||||
StringWriter writer = new StringWriter();
|
|
||||||
StreamResult result = new StreamResult(writer);
|
|
||||||
TransformerFactory tf = TransformerFactory.newInstance();
|
|
||||||
Transformer transformer = tf.newTransformer();
|
|
||||||
transformer.transform(domSource, result);
|
|
||||||
String wapProvisioning = writer.toString();
|
|
||||||
|
|
||||||
return wapProvisioning;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnrollmentResponseFile(String enrollmentResponseFile) {
|
|
||||||
this.enrollmentResponseFile = enrollmentResponseFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWapProvisioningXmlFile(String wapProvisioningXmlFile) {
|
|
||||||
this.wapProvisioningXmlFile = wapProvisioningXmlFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPrivatePemKeyFilePath(String privatePemKeyFilePath) {
|
|
||||||
this.privatePemKeyFilePath = privatePemKeyFilePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCaCertificateFilePath(String caCertificateFilePath) {
|
|
||||||
this.caCertificateFilePath = caCertificateFilePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPrivateKey(PrivateKey privateKey) {
|
|
||||||
this.privateKey = privateKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRooCACertificate(X509Certificate rooCACertificate) {
|
|
||||||
this.rooCACertificate = rooCACertificate;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class MyNamespaceContext implements NamespaceContext {
|
|
||||||
|
|
||||||
public String getNamespaceURI(String prefix) {
|
|
||||||
|
|
||||||
if ("s".equals(prefix)) {
|
|
||||||
return "http://www.w3.org/2003/05/soap-envelope";
|
|
||||||
} else if ("wst".equals(prefix)) {
|
|
||||||
return "http://docs.oasis-open.org/ws-sx/ws-trust/200512";
|
|
||||||
} else if ("wsse".equals(prefix)) {
|
|
||||||
return "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPrefix(String namespaceURI) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Iterator getPrefixes(String namespaceURI) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,92 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2014, 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 cdm.api.windows.util;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.bouncycastle.asn1.x500.X500Name;
|
|
||||||
import org.bouncycastle.cert.X509v3CertificateBuilder;
|
|
||||||
import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter;
|
|
||||||
import org.bouncycastle.cert.jcajce.JcaX509ExtensionUtils;
|
|
||||||
import org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder;
|
|
||||||
import org.bouncycastle.operator.ContentSigner;
|
|
||||||
import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
|
|
||||||
import org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequest;
|
|
||||||
|
|
||||||
import java.math.BigInteger;
|
|
||||||
import java.security.PrivateKey;
|
|
||||||
import java.security.SecureRandom;
|
|
||||||
import java.security.cert.X509Certificate;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class CertificateSigningService {
|
|
||||||
|
|
||||||
private static Logger LOGGER = Logger.getLogger(CertificateSigningService.class);
|
|
||||||
|
|
||||||
public static X509Certificate signCSR(JcaPKCS10CertificationRequest jcaRequest,
|
|
||||||
PrivateKey privateKey, X509Certificate caCert)
|
|
||||||
throws Exception {
|
|
||||||
try {
|
|
||||||
|
|
||||||
X509v3CertificateBuilder certificateBuilder = new JcaX509v3CertificateBuilder(caCert,
|
|
||||||
BigInteger
|
|
||||||
.valueOf(
|
|
||||||
new SecureRandom()
|
|
||||||
.nextInt(
|
|
||||||
Integer.MAX_VALUE)),
|
|
||||||
new Date(
|
|
||||||
System.currentTimeMillis() -
|
|
||||||
1000L *
|
|
||||||
60 *
|
|
||||||
60 *
|
|
||||||
24 *
|
|
||||||
30),
|
|
||||||
new Date(
|
|
||||||
System.currentTimeMillis() +
|
|
||||||
(1000L *
|
|
||||||
60 *
|
|
||||||
60 *
|
|
||||||
24 *
|
|
||||||
365 *
|
|
||||||
10)),
|
|
||||||
new X500Name(
|
|
||||||
"CN=abimaran"),
|
|
||||||
jcaRequest
|
|
||||||
.getPublicKey());
|
|
||||||
|
|
||||||
JcaX509ExtensionUtils extUtils = new JcaX509ExtensionUtils();
|
|
||||||
|
|
||||||
ContentSigner signer =
|
|
||||||
new JcaContentSignerBuilder("SHA1withRSA").setProvider("BC").build(privateKey);
|
|
||||||
|
|
||||||
X509Certificate theCert =
|
|
||||||
new JcaX509CertificateConverter().setProvider("BC").getCertificate(
|
|
||||||
certificateBuilder.build(signer));
|
|
||||||
|
|
||||||
LOGGER.info("Signed Certificate CN : " + theCert.getSubjectDN().getName());
|
|
||||||
|
|
||||||
LOGGER.info("Signed CSR's public key : " + theCert.getPublicKey());
|
|
||||||
|
|
||||||
return theCert;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new Exception("Error in signing the certificate", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed 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 cdm.api.windows.util;
|
|
||||||
|
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* WindowsAPIUtil class provides utility function used by Android REST-API classes.
|
|
||||||
*/
|
|
||||||
public class WindowsAPIUtil {
|
|
||||||
|
|
||||||
public static Device convertToDeviceObject(JsonObject json){
|
|
||||||
Device device = new Device();
|
|
||||||
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
|
||||||
device.setName("Test Device");
|
|
||||||
device.setOwner("harshan");
|
|
||||||
return device;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DeviceIdentifier convertToDeviceIdentifierObject(String deviceId){
|
|
||||||
DeviceIdentifier identifier = new DeviceIdentifier();
|
|
||||||
identifier.setId(deviceId);
|
|
||||||
identifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
|
||||||
return identifier;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,52 +0,0 @@
|
|||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xmlns:jaxws="http://cxf.apache.org/jaxws"
|
|
||||||
xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
|
|
||||||
xmlns:sec="http://cxf.apache.org/configuration/security"
|
|
||||||
xmlns:context="http://www.springframework.org/schema/context"
|
|
||||||
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
|
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
|
|
||||||
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://www.springframework.org/schema/context
|
|
||||||
http://www.springframework.org/schema/context/spring-context.xsd
|
|
||||||
http://cxf.apache.org/transports/http/configuration
|
|
||||||
http://cxf.apache.org/schemas/configuration/http-conf.xsd
|
|
||||||
http://cxf.apache.org/transports/http-jetty/configuration
|
|
||||||
http://cxf.apache.org/schemas/configuration/http-jetty.xsd
|
|
||||||
http://cxf.apache.org/transports/http/configuration
|
|
||||||
http://cxf.apache.org/schemas/configuration/http-conf.xsd
|
|
||||||
http://cxf.apache.org/transports/http-jetty/configuration
|
|
||||||
http://cxf.apache.org/schemas/configuration/security.xsd
|
|
||||||
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
|
|
||||||
|
|
||||||
<import resource="classpath:META-INF/cxf/cxf.xml"/>
|
|
||||||
<import resource="classpath:META-INF/cxf/cxf-extension-xml.xml"/>
|
|
||||||
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
|
|
||||||
|
|
||||||
<context:property-placeholder location="classpath:windows-mdm-server.properties"/>
|
|
||||||
|
|
||||||
<bean id="discoveryService" class="cdm.api.windows.impl.DiscoveryServiceImpl">
|
|
||||||
<property name="discoveryServiceFileName" value="${discovery.service.file.location}"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="userEnrollmentService" class="cdm.api.windows.impl.EnrolmentServiceImpl" init-method="init">
|
|
||||||
<property name="enrollmentResponseFile" value="${enrollment.service.file.location}"/>
|
|
||||||
<property name="responseFile" value="${policy.certificate.file.location}"/>
|
|
||||||
<property name="wapProvisioningXmlFile" value="${enrollment.service.wap.provisioning.file.location}"/>
|
|
||||||
<property name="privatePemKeyFilePath" value="./conf/ca_private.key"/>
|
|
||||||
<property name="caCertificateFilePath" value="./conf/ca_cert.pem"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<jaxrs:server name="windowsMDMRest" address="${service.url}">
|
|
||||||
<jaxrs:serviceBeans>
|
|
||||||
<ref bean="discoveryService"/>
|
|
||||||
<ref bean="userEnrollmentService"/>
|
|
||||||
</jaxrs:serviceBeans>
|
|
||||||
<jaxrs:providers>
|
|
||||||
<ref bean="jaxbProvider"/>
|
|
||||||
</jaxrs:providers>
|
|
||||||
</jaxrs:server>
|
|
||||||
|
|
||||||
<bean id="jaxbProvider" class="org.apache.cxf.jaxrs.provider.JAXBElementProvider">
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
</beans>
|
|
||||||
@ -1,20 +0,0 @@
|
|||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIDXDCCAkQCCQDWxw0vNF9H8DANBgkqhkiG9w0BAQUFADBwMQswCQYDVQQGEwJM
|
|
||||||
SzEQMA4GA1UECBMHQ29sb21ibzEQMA4GA1UEBxMHQ29sb21ibzENMAsGA1UEChME
|
|
||||||
d3NvMjEPMA0GA1UECxMGbW9iaWxlMR0wGwYDVQQDFBRjYV93c28yV2luZG93c01v
|
|
||||||
YmlsZTAeFw0xNDA3MDcxMDE4MDhaFw0xNTA3MDcxMDE4MDhaMHAxCzAJBgNVBAYT
|
|
||||||
AkxLMRAwDgYDVQQIEwdDb2xvbWJvMRAwDgYDVQQHEwdDb2xvbWJvMQ0wCwYDVQQK
|
|
||||||
EwR3c28yMQ8wDQYDVQQLEwZtb2JpbGUxHTAbBgNVBAMUFGNhX3dzbzJXaW5kb3dz
|
|
||||||
TW9iaWxlMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz+w93X1S8nOM
|
|
||||||
VM3ScGP8XY9+PnoUaFZgKaD3d9Z6cj4HPKjIzv8iTMx9JBfDjSsLiks5nJqxm1in
|
|
||||||
juck7n0tl/CZ5L2j/3DhsA4D0Ngp5JsH5ZF+Vu2T+z8wUq8UwGD6qsn/EP9jBbj/
|
|
||||||
WN0TtOPcfhOhfJVxaNOrt+9htYad9WOeU8Rh+CIb5oQrigEd417e5d5j4wcU8QLj
|
|
||||||
sVQQ8WRCYDrnKKof834ZnViBYX4UAdLtXkWFtKcD0RM/cB2LdjydwP3HEj6pkwjT
|
|
||||||
hRLGHdVF21VCbKOF6mnQagvuseT/ynioBNY60TXb283BQ6YrDfMytvRuzguEQ/7/
|
|
||||||
AsTPclNZxQIDAQABMA0GCSqGSIb3DQEBBQUAA4IBAQB3cwy5pibn009WvAYzmw9B
|
|
||||||
oB77bt21GQO4gFLJlNkvIRrneE5SinjoO6ezWOgY3+8t9ViNeD874momq4kuE6Hb
|
|
||||||
XDZE1qqinJlqfMJQuEaFkDZKg55kO66wy5+8ioFhA9V8SpeM+SYy3ENBucxiDLQE
|
|
||||||
ZhM7RKJCpSIq0rRHJyBRbs6GoW7cOB5QQcFDfSW+/CajicWzeD/OJMIfjJezCsZ8
|
|
||||||
GNXJpyAS/Te+ysHlfmrKMb1VMZphFNiTmpEx8OI8F/kbhmdwePaZ3SOw2kJp8e3v
|
|
||||||
Ke4/zPwB95wjz8luzU+PbqNO2K4ZKtXHk6rx5yybR1UBpYINvUEjsRI3hgy1IoE+
|
|
||||||
-----END CERTIFICATE-----
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
-----BEGIN RSA PRIVATE KEY-----
|
|
||||||
MIIEpAIBAAKCAQEAz+w93X1S8nOMVM3ScGP8XY9+PnoUaFZgKaD3d9Z6cj4HPKjI
|
|
||||||
zv8iTMx9JBfDjSsLiks5nJqxm1injuck7n0tl/CZ5L2j/3DhsA4D0Ngp5JsH5ZF+
|
|
||||||
Vu2T+z8wUq8UwGD6qsn/EP9jBbj/WN0TtOPcfhOhfJVxaNOrt+9htYad9WOeU8Rh
|
|
||||||
+CIb5oQrigEd417e5d5j4wcU8QLjsVQQ8WRCYDrnKKof834ZnViBYX4UAdLtXkWF
|
|
||||||
tKcD0RM/cB2LdjydwP3HEj6pkwjThRLGHdVF21VCbKOF6mnQagvuseT/ynioBNY6
|
|
||||||
0TXb283BQ6YrDfMytvRuzguEQ/7/AsTPclNZxQIDAQABAoIBAQCrNz+Od1fpnOrv
|
|
||||||
Hnnu4Pb82F+99Ot/K7mOLiX6Qdyc3KU690Y85m2JTk6yfPsj8VFUdTOg2OXuJWf9
|
|
||||||
TivkU6JK3u7rJJq6i2rdffz4aji9Lkina1LdJFBacaNKQzBUZsekAiiPB660FK34
|
|
||||||
sDw9FfIIxAOTwsAb8UoTcgVE5PCIEx7R7YdAI0/mMnd98kTc2YdcnAmGwrDFQNer
|
|
||||||
eOLhq8H/6SxUADyos3s6Tgw3/yIo9BnBpe8uPNoakEPgYJLh263uF2rJ2h0+yLDV
|
|
||||||
9F9by+yFCqyVqS8P06NI+NMe8WsYJo99RGQsLZ7PsI5jiJSTRYgOF4ROQfAcCZiK
|
|
||||||
UWKCwcwhAoGBAPOg32J8AZX64FFDqyruN/1Q6hJfkVAVM+B3dxNAYIpccLuuxJ7x
|
|
||||||
JMIWkAFfBlOoaXZzxaDIXmXrd3h5qxRTd6W/gAR9nRko7YHaK7NszpEPA8hVOjjx
|
|
||||||
kkTNs/KjlELrLspRWL+iDqR5Nscw0V9y2D6tyYuGp475wK4PmKbgcKAdAoGBANp7
|
|
||||||
M9nFEAUTeHzdo9csbrGy6wUuCRlixFvXKOH+1ezeuNvxh0XtbJPj7FrPT4nuCKEV
|
|
||||||
Wud1w3/IRaeCYeKXaHk6eF8zN1gVkN0MAQJ+9KtfZ0QnmQSsluJfrUBGej6UYO0z
|
|
||||||
DUv5CLNYLPwOVGTb/jb5n+lY2IzjKmA+aWZRML/JAoGBAJSfUycVVzJTdXydt1Hd
|
|
||||||
OTLDpcfHnTIpfRg2SOHpp/tAIVWdbD06Bp6QfREZExb96jhkr+9BzLSITL2mG4Ou
|
|
||||||
15K5nDMhHjE3Eozgt0Ah5HIBouEXfQk39W8bvecLe2rHZifuMCHXju8vMweY9GEy
|
|
||||||
AlFaW1VOs/E40x5cTVegG5TRAoGANLxmUJtTeZYwkBtDr+2GrpfcSLzK73i6otx1
|
|
||||||
fs9vPaSpBFXxa/yaJ7xtUaIWtdlh9dfcwF/Zl590yLEdBX+8dP6bDYekRTu3YtPB
|
|
||||||
7qNMVY1KtNXGBq3OIcgsXoZkfXR9TOP0wrDS289d1F11G39KhmSMp9uNMbynfuGx
|
|
||||||
uUPBu5kCgYA1UUtQkVPbkKaaopSrDkqAJDlsUnNVkvXH5yWqdAYI2Frw1iOwhED3
|
|
||||||
cKmwAejf8nl1HPwfDTGQMRB5PCDkK7mWJ5w9W4MUbJ7ZiNPHloZutUTcw3Nz58cn
|
|
||||||
OZMZGR/Trtn+YLoj2526NPwKqlw0bRB27UR0KOdgPOHynI3uYPnwgQ==
|
|
||||||
-----END RSA PRIVATE KEY-----
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"
|
|
||||||
xmlns:a="http://www.w3.org/2005/08/addressing">
|
|
||||||
<s:Header>
|
|
||||||
<a:Action s:mustUnderstand="1">
|
|
||||||
http://schemas.microsoft.com/windows/management/2012/01/enrollment/IDiscoveryService/DiscoverResponse
|
|
||||||
</a:Action>
|
|
||||||
<ActivityId>
|
|
||||||
d9eb2fdd-e38a-46ee-bd93-aea9dc86a3b8
|
|
||||||
</ActivityId>
|
|
||||||
<a:RelatesTo>urn:uuid: 748132ec-a575-4329-b01b-6171a9cf8478</a:RelatesTo>
|
|
||||||
</s:Header>
|
|
||||||
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
|
||||||
<DiscoverResponse
|
|
||||||
xmlns="http://schemas.microsoft.com/windows/management/2012/01/enrollment">
|
|
||||||
<DiscoverResult>
|
|
||||||
<AuthPolicy>OnPremise</AuthPolicy>
|
|
||||||
<EnrollmentPolicyServiceUrl>
|
|
||||||
https://EnterpriseEnrollment.wso2.com/ENROLLMENTSERVER/PolicyEnrollmentWebservice.svc
|
|
||||||
</EnrollmentPolicyServiceUrl>
|
|
||||||
<EnrollmentServiceUrl>
|
|
||||||
https://EnterpriseEnrollment.wso2.com/ENROLLMENTSERVER/DeviceEnrollmentWebservice.svc
|
|
||||||
</EnrollmentServiceUrl>
|
|
||||||
</DiscoverResult>
|
|
||||||
</DiscoverResponse>
|
|
||||||
</s:Body>
|
|
||||||
</s:Envelope>
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://www.w3.org/2005/08/addressing"
|
|
||||||
xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
|
|
||||||
<s:Header>
|
|
||||||
<Action s:mustUnderstand="1">http://schemas.microsoft.com/windows/pki/2009/01/enrollment/RSTRC/wstep</Action>
|
|
||||||
<a:RelatesTo>urn:uuid:81a5419a-496b-474f-a627-5cdd33eed8ab</a:RelatesTo>
|
|
||||||
<o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
|
|
||||||
<u:Timestamp u:Id="_0">
|
|
||||||
<u:Created>2012-08-02T00:32:59.420Z</u:Created>
|
|
||||||
<u:Expires>2014-08-02T00:37:59.420Z</u:Expires>
|
|
||||||
</u:Timestamp>
|
|
||||||
</o:Security>
|
|
||||||
</s:Header>
|
|
||||||
<s:Body>
|
|
||||||
<RequestSecurityTokenResponseCollection xmlns="http://docs.oasis-open.org/ws-sx/ws-trust/200512">
|
|
||||||
<RequestSecurityTokenResponse>
|
|
||||||
<TokenType>http://schemas.microsoft.com/5.0.0.0/ConfigurationManager/Enrollment/DeviceEnrollmentToken</TokenType>
|
|
||||||
<RequestedSecurityToken>
|
|
||||||
<BinarySecurityToken ValueType="http://schemas.microsoft.com/5.0.0.0/ConfigurationManager/Enrollment/DeviceEnrollmentProvisionDoc"
|
|
||||||
EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd#base64binary"
|
|
||||||
xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
|
|
||||||
</BinarySecurityToken>
|
|
||||||
</RequestedSecurityToken>
|
|
||||||
<RequestID xmlns="http://schemas.microsoft.com/windows/pki/2009/01/enrollment">0</RequestID>
|
|
||||||
</RequestSecurityTokenResponse>
|
|
||||||
</RequestSecurityTokenResponseCollection>
|
|
||||||
</s:Body>
|
|
||||||
</s:Envelope>
|
|
||||||
@ -1,50 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
|
|
||||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
|
||||||
|
|
||||||
<log4j:configuration debug="false" xmlns:log4j="http://jakarta.apache.org/log4j/">
|
|
||||||
|
|
||||||
<appender name="error" class="org.apache.log4j.DailyRollingFileAppender">
|
|
||||||
<param name="File" value="logs/windows_mdm_error.log"/>
|
|
||||||
<param name="Threshold" value="error"/>
|
|
||||||
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
|
|
||||||
<layout class="org.apache.log4j.PatternLayout">
|
|
||||||
<param name="ConversionPattern" value="%d{DATE} %-5p %c{1} - [%x] %m%n"/>
|
|
||||||
</layout>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<appender name="debug" class="org.apache.log4j.DailyRollingFileAppender">
|
|
||||||
<param name="File" value="logs/windows_mdm_debug.log"/>
|
|
||||||
<param name="Threshold" value="debug"/>
|
|
||||||
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
|
|
||||||
<layout class="org.apache.log4j.PatternLayout">
|
|
||||||
<param name="ConversionPattern" value="%d{DATE} %-5p %c{1} - [%x] %m%n"/>
|
|
||||||
</layout>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<appender name="trans" class="org.apache.log4j.DailyRollingFileAppender">
|
|
||||||
<param name="File" value="logs/windows_mdm__trans.log" />
|
|
||||||
<param name="Threshold" value="info" />
|
|
||||||
<param name="DatePattern" value="'.'yyyy-MM-dd" />
|
|
||||||
<layout class="org.apache.log4j.PatternLayout">
|
|
||||||
<param name="ConversionPattern" value="%m%n" />
|
|
||||||
</layout>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<category name="org.apache.cxf" additivity="false">
|
|
||||||
<priority value="trace"/>
|
|
||||||
<appender-ref ref="debug"/>
|
|
||||||
<appender-ref ref="error"/>
|
|
||||||
</category>
|
|
||||||
|
|
||||||
<category name="org.springframework" additivity="false">
|
|
||||||
<priority value="info"/>
|
|
||||||
<appender-ref ref="error"/>
|
|
||||||
</category>
|
|
||||||
|
|
||||||
<root>
|
|
||||||
<appender-ref ref="debug"/>
|
|
||||||
<appender-ref ref="error"/>
|
|
||||||
</root>
|
|
||||||
|
|
||||||
</log4j:configuration>
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
<s:Envelope
|
|
||||||
xmlns:a="http://www.w3.org/2005/08/addressing"
|
|
||||||
xmlns:s="http://www.w3.org/2003/05/soap-envelope">
|
|
||||||
<s:Header>
|
|
||||||
<a:Action s:mustUnderstand="1">
|
|
||||||
http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy/IPolicy/GetPoliciesResponse
|
|
||||||
</a:Action>
|
|
||||||
</s:Header>
|
|
||||||
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
|
||||||
<GetPoliciesResponse xmlns="http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy">
|
|
||||||
|
|
||||||
</GetPoliciesResponse>
|
|
||||||
</s:Body>
|
|
||||||
</s:Envelope>
|
|
||||||
@ -1,80 +0,0 @@
|
|||||||
<wap-provisioningdoc version="1.1">
|
|
||||||
<characteristic type="CertificateStore">
|
|
||||||
<characteristic type="Root">
|
|
||||||
<characteristic type="System">
|
|
||||||
<characteristic type="031336C933CC7E228B88880D78824FB2909A0A2F">
|
|
||||||
<parm name="EncodedCertificate" value=""/>
|
|
||||||
</characteristic>
|
|
||||||
</characteristic>
|
|
||||||
</characteristic>
|
|
||||||
<characteristic type="My" >
|
|
||||||
<!-- "My" and “User” are case-sensitive -->
|
|
||||||
<characteristic type="User">
|
|
||||||
<characteristic type="F9A4F20FC50D990FDD0E3DB9AFCBF401818D5462">
|
|
||||||
<parm name="EncodedCertificate" value=""/>
|
|
||||||
</characteristic>
|
|
||||||
<characteristic type="PrivateKeyContainer"/>
|
|
||||||
<!-- This tag must be present for XML syntax correctness. -->
|
|
||||||
</characteristic>
|
|
||||||
</characteristic>
|
|
||||||
</characteristic>
|
|
||||||
<characteristic type="APPLICATION">
|
|
||||||
<parm name="APPID" value="w7"/>
|
|
||||||
<parm name="PROVIDER-ID" value="TestMDMServer"/>
|
|
||||||
<parm name="NAME" value="wso2"/>
|
|
||||||
<parm name="ADDR" value="https://EnterpriseEnrollment.wso2.com:443/mdm/WindowsPhone.ashx"/>
|
|
||||||
<parm name="CONNRETRYFREQ" value="6" />
|
|
||||||
<parm name="INITIALBACKOFFTIME" value="30000" />
|
|
||||||
<parm name="MAXBACKOFFTIME" value="120000" />
|
|
||||||
<parm name="BACKCOMPATRETRYDISABLED" />
|
|
||||||
<parm name="DEFAULTENCODING" value="application/vnd.syncml.dm+wbxml" />
|
|
||||||
<parm name="SSLCLIENTCERTSEARCHCRITERIA" value="CN%3Dabimaran&Stores=My%5CUser"/>
|
|
||||||
<characteristic type="APPAUTH">
|
|
||||||
<parm name="AAUTHLEVEL" value="CLIENT"/>
|
|
||||||
<parm name="AAUTHTYPE" value="DIGEST"/>
|
|
||||||
<parm name="AAUTHSECRET" value="password1"/>
|
|
||||||
<parm name="AAUTHDATA" value="nonce"/>
|
|
||||||
</characteristic>
|
|
||||||
<characteristic type="APPAUTH">
|
|
||||||
<parm name="AAUTHLEVEL" value="APPSRV"/>
|
|
||||||
<parm name="AAUTHTYPE" value="BASIC"/>
|
|
||||||
<parm name="AAUTHNAME" value="testclient"/>
|
|
||||||
<parm name="AAUTHSECRET" value="password2"/>
|
|
||||||
</characteristic>
|
|
||||||
</characteristic>
|
|
||||||
<characteristic type="Registry">
|
|
||||||
<characteristic type="HKLM\Software\Microsoft\Enrollment">
|
|
||||||
<parm name="RenewalPeriod" value="42" datatype="integer" />
|
|
||||||
</characteristic>
|
|
||||||
<characteristic type="HKLM\Software\Microsoft\Enrollment\OmaDmRetry">
|
|
||||||
<parm name="NumRetries" value="8" datatype="integer" />
|
|
||||||
<parm name="RetryInterval" value="15" datatype="integer" />
|
|
||||||
<parm name="AuxNumRetries" value="5" datatype="integer" />
|
|
||||||
<parm name="AuxRetryInterval" value="3" datatype="integer" />
|
|
||||||
<parm name="Aux2NumRetries" value="0" datatype="integer" />
|
|
||||||
<!-- Retry waiting interval less than 60 minutes isn’t suggested due to impact to data
|
|
||||||
comsumption and battery life. -->
|
|
||||||
<parm name="Aux2RetryInterval" value="480" datatype="integer" />
|
|
||||||
</characteristic>
|
|
||||||
</characteristic>
|
|
||||||
<characteristic type="DMClient">
|
|
||||||
<characteristic type="Provider">
|
|
||||||
<characteristic type="TestMDMServer">
|
|
||||||
<parm name="EntDeviceName" value="Administrator_WindowsPhone" datatype="string" />
|
|
||||||
</characteristic>
|
|
||||||
</characteristic>
|
|
||||||
</characteristic>
|
|
||||||
<!-- Specify application Enrollment Token (AET) in EnrollmenToken node, provide URL for
|
|
||||||
downloading company app hub apps, specify client certificate search criteria for downloading
|
|
||||||
company app from SSL server that requires client cert based authentication . -->
|
|
||||||
<characteristic type="EnterpriseAppManagement">
|
|
||||||
<characteristic type="EnterpriseIDInsertedHere">
|
|
||||||
<parm datatype="string" name="EnrollmentToken" value="AETInsertedHere"/>
|
|
||||||
<parm datatype="string" name="StoreProductId" value="AppProductIDInsertedHere"/>
|
|
||||||
<parm datatype="string" name="StoreURI" value="HTTPS://DM.contoso.com:443/EnrollmentServer/clientcabs/EnterpriseApp1.xap"/>
|
|
||||||
<parm datatype="string" name="StoreName" value="Wso2 App Store"/>
|
|
||||||
<parm datatype="string" name="CertificateSearchCriteria" value="CN%3Dabimaran"/>
|
|
||||||
<parm datatype="string" name="CRLCheck" value="0"/>
|
|
||||||
</characteristic>
|
|
||||||
</characteristic>
|
|
||||||
</wap-provisioningdoc>
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
service.url=http://0.0.0.0:9090
|
|
||||||
|
|
||||||
|
|
||||||
discovery.service.file.location=./conf/discover-service.xml
|
|
||||||
policy.certificate.file.location=./conf/policy-service.xml
|
|
||||||
enrollment.service.file.location=./conf/enrollment-service.xml
|
|
||||||
|
|
||||||
enrollment.service.wap.provisioning.file.location=./conf/wap-provisioning.xml
|
|
||||||
@ -23,22 +23,52 @@
|
|||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
|
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
|
||||||
|
xmlns:jaxws="http://cxf.apache.org/jaxws"
|
||||||
xsi:schemaLocation="
|
xsi:schemaLocation="
|
||||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||||
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
|
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
|
||||||
|
|
||||||
|
|
||||||
<jaxrs:server id="ServiceDiscoveryService" address="/devices">
|
<jaxws:endpoint
|
||||||
|
id="DiscoveryService"
|
||||||
|
implementor="cdm.api.windows.DiscoveryService.impl.DiscoveryServiceGetImpl"
|
||||||
|
address="/test/send"/>
|
||||||
|
|
||||||
|
<jaxrs:server id="DiscoveryService_rest" address="/test/send2">
|
||||||
<jaxrs:serviceBeans>
|
<jaxrs:serviceBeans>
|
||||||
<ref bean="ServiceDiscoveryServiceBean"/>
|
<ref bean="DiscoveryService_rest_bean"/>
|
||||||
</jaxrs:serviceBeans>
|
</jaxrs:serviceBeans>
|
||||||
</jaxrs:server>
|
</jaxrs:server>
|
||||||
<jaxrs:server id="enrollmentService" address="/enrollment">
|
<bean id="DiscoveryService_rest_bean" class="cdm.api.windows.DiscoveryService.impl.DiscoveryServiceGetImpl"/>
|
||||||
<jaxrs:serviceBeans>
|
|
||||||
<ref bean="enrollmentServiceBean"/>
|
|
||||||
</jaxrs:serviceBeans>
|
|
||||||
</jaxrs:server>
|
<jaxws:endpoint
|
||||||
<bean id="ServiceDiscoveryServiceBean" class="cdm.api.windows.impl.DiscoveryServiceImpl"/>
|
id="EnrollmentPolicyService"
|
||||||
<bean id="enrollmentServiceBean" class="cdm.api.windows.impl.EnrolmentServiceImpl"/>
|
implementor="cdm.api.windows.xcep.impl.xcepimpl"
|
||||||
|
address="/test/xcep">
|
||||||
|
|
||||||
|
<jaxws:handlers>
|
||||||
|
<bean id="serviceOptionsHandler_xcep"
|
||||||
|
class="com.ex.xcep.impl.PPSRSOApMessageHandler"/>
|
||||||
|
</jaxws:handlers>
|
||||||
|
<jaxws:properties>
|
||||||
|
<entry key="ws-security.callback-handler" value-ref="myPasswordCallback"/>
|
||||||
|
</jaxws:properties>
|
||||||
|
</jaxws:endpoint>
|
||||||
|
<bean id="myPasswordCallback" class="cdm.api.windows.xcep.util.ServerPasswordCallback"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<jaxws:endpoint
|
||||||
|
id="CertificateEnrollmentService"
|
||||||
|
implementor="cdm.api.windows.wstep.impl.CertificateEnrollmentServiceImpl"
|
||||||
|
address="/cert">
|
||||||
|
<jaxws:handlers>
|
||||||
|
<bean id="serviceOptionsHandler_wstep"
|
||||||
|
class="cdm.api.windows.wstep.util.PPSRSOApMessageHandler"/>
|
||||||
|
</jaxws:handlers>
|
||||||
|
</jaxws:endpoint>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
|
||||||
|
|||||||
@ -20,10 +20,16 @@
|
|||||||
-->
|
-->
|
||||||
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
|
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
|
||||||
<display-name>CDM-Windows-API</display-name>
|
<display-name>CDM-Windows-API</display-name>
|
||||||
|
|
||||||
|
<context-param>
|
||||||
|
<param-name>contextConfigLocation</param-name>
|
||||||
|
<param-value>/WEB-INF/cxf-servlet.xml</param-value>
|
||||||
|
</context-param>
|
||||||
|
|
||||||
<servlet>
|
<servlet>
|
||||||
<description>JAX-WS/JAX-RS Endpoint</description>
|
<description>JAX-WS/JAX-RS-windows Endpoint</description>
|
||||||
<display-name>JAX-WS/JAX-RS Servlet</display-name>
|
<display-name>JAX-WS/JAX-RS-windows Servlet</display-name>
|
||||||
<servlet-name>JAXServlet</servlet-name>
|
<servlet-name>JAXServlet-windows</servlet-name>
|
||||||
<servlet-class>
|
<servlet-class>
|
||||||
org.apache.cxf.transport.servlet.CXFServlet
|
org.apache.cxf.transport.servlet.CXFServlet
|
||||||
</servlet-class>
|
</servlet-class>
|
||||||
@ -34,7 +40,7 @@
|
|||||||
<load-on-startup>1</load-on-startup>
|
<load-on-startup>1</load-on-startup>
|
||||||
</servlet>
|
</servlet>
|
||||||
<servlet-mapping>
|
<servlet-mapping>
|
||||||
<servlet-name>JAXServlet</servlet-name>
|
<servlet-name>JAXServlet-windows</servlet-name>
|
||||||
<url-pattern>/*</url-pattern>
|
<url-pattern>/*</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
<session-config>
|
<session-config>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user