mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
b702a72b2f
@ -22,13 +22,12 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||||||
/**
|
/**
|
||||||
* Class for holding data source configuration in mobile-config.xml at parsing with JAXB.
|
* Class for holding data source configuration in mobile-config.xml at parsing with JAXB.
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(name = "DataSourceConfiguration")
|
@XmlRootElement(name = "DataSourceConfiguration") public class MobileDataSourceConfig {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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 MobileDeviceOperationMappingDAO getMobileDeviceOperationDAO() {
|
||||||
return new FeatureDAOImpl(dataSource);
|
return new MobileDeviceOperationMappingDAOImpl(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FeaturePropertyDAO getFeaturePropertyDAO() {
|
public static MobileFeatureDAO getFeatureDAO() {
|
||||||
return new FeaturePropertyDAOImpl(dataSource);
|
return new MobileFeatureDAOImpl(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MobileDataSourceConfig getMobileDeviceManagementConfig() {
|
public static MobileFeaturePropertyDAO getFeaturePropertyDAO() {
|
||||||
return mobileDataSourceConfig;
|
return new MobileFeaturePropertyDAOImpl(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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,79 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015, 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.carbon.device.mgt.mobile.dao;
|
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperation;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class represents the mapping between device and operations.
|
|
||||||
*/
|
|
||||||
public interface MobileDeviceOperationDAO {
|
|
||||||
/**
|
|
||||||
* Add a new mapping to plugin device_operation table.
|
|
||||||
*
|
|
||||||
* @param deviceOperation DeviceOperation object that holds data related to the DeviceOperation
|
|
||||||
* to be inserted.
|
|
||||||
* @return The status of the operation. If the insert was successful or not.
|
|
||||||
* @throws MobileDeviceManagementDAOException
|
|
||||||
*/
|
|
||||||
boolean addMobileDeviceOperation(MobileDeviceOperation deviceOperation)
|
|
||||||
throws MobileDeviceManagementDAOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update a feature in the feature table.
|
|
||||||
*
|
|
||||||
* @param deviceOperation DeviceOperation object that holds data has to be updated.
|
|
||||||
* @return The status of the operation. If the update was successful or not.
|
|
||||||
* @throws MobileDeviceManagementDAOException
|
|
||||||
*/
|
|
||||||
boolean updateMobileDeviceOperation(MobileDeviceOperation deviceOperation)
|
|
||||||
throws MobileDeviceManagementDAOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete a given device operation from device operation table.
|
|
||||||
*
|
|
||||||
* @param deviceId Device id of the mapping to be deleted.
|
|
||||||
* @param operationId Operation id of the mapping to be deleted.
|
|
||||||
* @return The status of the operation. If the deletion was successful or not.
|
|
||||||
* @throws MobileDeviceManagementDAOException
|
|
||||||
*/
|
|
||||||
boolean deleteMobileDeviceOperation(String deviceId, int operationId)
|
|
||||||
throws MobileDeviceManagementDAOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve a given device operation from plugin database.
|
|
||||||
*
|
|
||||||
* @param deviceId Device id of the mapping to be retrieved.
|
|
||||||
* @param operationId Operation id of the mapping to be retrieved.
|
|
||||||
* @return DeviceOperation object that holds data of the device operation mapping represented by
|
|
||||||
* deviceId and operationId.
|
|
||||||
* @throws MobileDeviceManagementDAOException
|
|
||||||
*/
|
|
||||||
MobileDeviceOperation getMobileDeviceOperation(String deviceId, int operationId)
|
|
||||||
throws MobileDeviceManagementDAOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve all the device operation mapping from plugin database.
|
|
||||||
*
|
|
||||||
* @return Device operation mapping object list.
|
|
||||||
* @throws MobileDeviceManagementDAOException
|
|
||||||
*/
|
|
||||||
List<MobileDeviceOperation> getAllMobileDeviceOperationsOfDevice(String deviceId)
|
|
||||||
throws MobileDeviceManagementDAOException;
|
|
||||||
}
|
|
||||||
@ -0,0 +1,110 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, 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.carbon.device.mgt.mobile.dao;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperationMapping;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents the mapping between mobile device and operations.
|
||||||
|
*/
|
||||||
|
public interface MobileDeviceOperationMappingDAO {
|
||||||
|
/**
|
||||||
|
* Add a new mobile device operation mapping to the table.
|
||||||
|
*
|
||||||
|
* @param deviceOperation MobileDeviceOperation object that holds data related to the MobileDeviceOperation
|
||||||
|
* to be inserted.
|
||||||
|
* @return The status of the operation. If the insert was successful or not.
|
||||||
|
* @throws MobileDeviceManagementDAOException
|
||||||
|
*/
|
||||||
|
boolean addMobileDeviceOperation(MobileDeviceOperationMapping deviceOperation)
|
||||||
|
throws MobileDeviceManagementDAOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a mobile device operation mapping.
|
||||||
|
*
|
||||||
|
* @param deviceOperation MobileDeviceOperation object that holds data has to be updated.
|
||||||
|
* @return The status of the operation. If the update was successful or not.
|
||||||
|
* @throws MobileDeviceManagementDAOException
|
||||||
|
*/
|
||||||
|
boolean updateMobileDeviceOperation(MobileDeviceOperationMapping deviceOperation)
|
||||||
|
throws MobileDeviceManagementDAOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a mobile device operation mapping to In-Progress state.
|
||||||
|
*
|
||||||
|
* @param deviceId Device id of the mapping to be deleted.
|
||||||
|
* @param operationId Operation id of the mapping to be deleted.
|
||||||
|
* @return The status of the operation. If the update was successful or not.
|
||||||
|
* @throws MobileDeviceManagementDAOException
|
||||||
|
*/
|
||||||
|
boolean updateMobileDeviceOperationToInProgress(String deviceId, int operationId)
|
||||||
|
throws MobileDeviceManagementDAOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a mobile device operation mapping to completed state.
|
||||||
|
*
|
||||||
|
* @param deviceId Device id of the mapping to be deleted.
|
||||||
|
* @param operationId Operation id of the mapping to be deleted.
|
||||||
|
* @return The status of the operation. If the update was successful or not.
|
||||||
|
* @throws MobileDeviceManagementDAOException
|
||||||
|
*/
|
||||||
|
boolean updateMobileDeviceOperationToCompleted(String deviceId, int operationId)
|
||||||
|
throws MobileDeviceManagementDAOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a given mobile device operation mapping from table.
|
||||||
|
*
|
||||||
|
* @param deviceId Device id of the mapping to be deleted.
|
||||||
|
* @param operationId Operation id of the mapping to be deleted.
|
||||||
|
* @return The status of the operation. If the deletion was successful or not.
|
||||||
|
* @throws MobileDeviceManagementDAOException
|
||||||
|
*/
|
||||||
|
boolean deleteMobileDeviceOperation(String deviceId, int operationId)
|
||||||
|
throws MobileDeviceManagementDAOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a given mobile device operation from the plugin database.
|
||||||
|
*
|
||||||
|
* @param deviceId Device id of the mapping to be retrieved.
|
||||||
|
* @param operationId Operation id of the mapping to be retrieved.
|
||||||
|
* @return MobileDeviceOperation object that holds data of the device operation mapping represented by
|
||||||
|
* deviceId and operationId.
|
||||||
|
* @throws MobileDeviceManagementDAOException
|
||||||
|
*/
|
||||||
|
MobileDeviceOperationMapping getMobileDeviceOperation(String deviceId, int operationId)
|
||||||
|
throws MobileDeviceManagementDAOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves all the of mobile device operation mappings relavent to the given mobile device.
|
||||||
|
*
|
||||||
|
* @return Device operation mapping object list.
|
||||||
|
* @throws MobileDeviceManagementDAOException
|
||||||
|
*/
|
||||||
|
List<MobileDeviceOperationMapping> getAllMobileDeviceOperationsOfDevice(String deviceId)
|
||||||
|
throws MobileDeviceManagementDAOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves all the pending device operation mappings of a mobiel device.
|
||||||
|
*
|
||||||
|
* @return Device operation mapping object list.
|
||||||
|
* @throws MobileDeviceManagementDAOException
|
||||||
|
*/
|
||||||
|
List<MobileDeviceOperationMapping> getAllPendingOperationsOfMobileDevice(String deviceId)
|
||||||
|
throws MobileDeviceManagementDAOException;
|
||||||
|
}
|
||||||
@ -16,33 +16,33 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.device.mgt.mobile.dao;
|
package org.wso2.carbon.device.mgt.mobile.dao;
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.dto.Feature;
|
import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents the key operations associated with persisting feature related
|
* This class represents the key operations associated with persisting mobile feature related
|
||||||
* information.
|
* information.
|
||||||
*/
|
*/
|
||||||
public interface FeatureDAO {
|
public interface MobileFeatureDAO {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new feature to feature table.
|
* Add a new feature to feature table.
|
||||||
*
|
*
|
||||||
* @param feature Feature object that holds data related to the feature to be inserted.
|
* @param mobileFeature Feature object that holds data related to the feature to be inserted.
|
||||||
* @return The status of the operation. If the insert was successful or not.
|
* @return The status of the operation. If the insert was successful or not.
|
||||||
* @throws MobileDeviceManagementDAOException
|
* @throws MobileDeviceManagementDAOException
|
||||||
*/
|
*/
|
||||||
boolean addFeature(Feature feature) throws MobileDeviceManagementDAOException;
|
boolean addFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a feature in the feature table.
|
* Update a feature in the feature table.
|
||||||
*
|
*
|
||||||
* @param feature Feature object that holds data has to be updated.
|
* @param mobileFeature Feature object that holds data has to be updated.
|
||||||
* @return The status of the operation. If the update was successful or not.
|
* @return The status of the operation. If the update was successful or not.
|
||||||
* @throws MobileDeviceManagementDAOException
|
* @throws MobileDeviceManagementDAOException
|
||||||
*/
|
*/
|
||||||
boolean updateFeature(Feature feature) throws MobileDeviceManagementDAOException;
|
boolean updateFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a feature from feature table when the feature id is given.
|
* Delete a feature from feature table when the feature id is given.
|
||||||
@ -69,7 +69,7 @@ public interface FeatureDAO {
|
|||||||
* @return Feature object that holds data of the feature represented by featureId.
|
* @return Feature object that holds data of the feature represented by featureId.
|
||||||
* @throws MobileDeviceManagementDAOException
|
* @throws MobileDeviceManagementDAOException
|
||||||
*/
|
*/
|
||||||
Feature getFeatureById(String featureId) throws MobileDeviceManagementDAOException;
|
MobileFeature getFeatureById(String featureId) throws MobileDeviceManagementDAOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a given feature from feature table when the feature code is given.
|
* Retrieve a given feature from feature table when the feature code is given.
|
||||||
@ -78,7 +78,7 @@ public interface FeatureDAO {
|
|||||||
* @return Feature object that holds data of the feature represented by featureCode.
|
* @return Feature object that holds data of the feature represented by featureCode.
|
||||||
* @throws MobileDeviceManagementDAOException
|
* @throws MobileDeviceManagementDAOException
|
||||||
*/
|
*/
|
||||||
Feature getFeatureByCode(String featureCode) throws MobileDeviceManagementDAOException;
|
MobileFeature getFeatureByCode(String featureCode) throws MobileDeviceManagementDAOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve all the features from plugin specific database.
|
* Retrieve all the features from plugin specific database.
|
||||||
@ -86,5 +86,5 @@ public interface FeatureDAO {
|
|||||||
* @return Feature object list.
|
* @return Feature object list.
|
||||||
* @throws MobileDeviceManagementDAOException
|
* @throws MobileDeviceManagementDAOException
|
||||||
*/
|
*/
|
||||||
List<Feature> getAllFeatures() throws MobileDeviceManagementDAOException;
|
List<MobileFeature> getAllFeatures() throws MobileDeviceManagementDAOException;
|
||||||
}
|
}
|
||||||
@ -16,33 +16,33 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.device.mgt.mobile.dao;
|
package org.wso2.carbon.device.mgt.mobile.dao;
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.dto.FeatureProperty;
|
import org.wso2.carbon.device.mgt.mobile.dto.MobileFeatureProperty;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents the key operations associated with persisting feature property related
|
* This class represents the key operations associated with persisting mobile feature property related
|
||||||
* information.
|
* information.
|
||||||
*/
|
*/
|
||||||
public interface FeaturePropertyDAO {
|
public interface MobileFeaturePropertyDAO {
|
||||||
/**
|
/**
|
||||||
* Add a new feature property to feature property table.
|
* Add a new feature property to feature property table.
|
||||||
*
|
*
|
||||||
* @param featureProperty Feature property object that holds data related to the feature property to be inserted.
|
* @param mobileFeatureProperty Feature property object that holds data related to the feature property to be inserted.
|
||||||
* @return The status of the operation. If the insert was successful or not.
|
* @return The status of the operation. If the insert was successful or not.
|
||||||
* @throws MobileDeviceManagementDAOException
|
* @throws MobileDeviceManagementDAOException
|
||||||
*/
|
*/
|
||||||
boolean addFeatureProperty(FeatureProperty featureProperty)
|
boolean addFeatureProperty(MobileFeatureProperty mobileFeatureProperty)
|
||||||
throws MobileDeviceManagementDAOException;
|
throws MobileDeviceManagementDAOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a feature property in the feature property table.
|
* Update a feature property in the feature property table.
|
||||||
*
|
*
|
||||||
* @param featureProperty Feature property object that holds data has to be updated.
|
* @param mobileFeatureProperty Feature property object that holds data has to be updated.
|
||||||
* @return The status of the operation. If the update was successful or not.
|
* @return The status of the operation. If the update was successful or not.
|
||||||
* @throws MobileDeviceManagementDAOException
|
* @throws MobileDeviceManagementDAOException
|
||||||
*/
|
*/
|
||||||
boolean updateFeatureProperty(FeatureProperty featureProperty)
|
boolean updateFeatureProperty(MobileFeatureProperty mobileFeatureProperty)
|
||||||
throws MobileDeviceManagementDAOException;
|
throws MobileDeviceManagementDAOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,7 +61,7 @@ public interface FeaturePropertyDAO {
|
|||||||
* @return Feature property object that holds data of the feature property represented by propertyId.
|
* @return Feature property object that holds data of the feature property represented by propertyId.
|
||||||
* @throws MobileDeviceManagementDAOException
|
* @throws MobileDeviceManagementDAOException
|
||||||
*/
|
*/
|
||||||
FeatureProperty getFeatureProperty(String property) throws MobileDeviceManagementDAOException;
|
MobileFeatureProperty getFeatureProperty(String property) throws MobileDeviceManagementDAOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a list of feature property corresponds to a feature id .
|
* Retrieve a list of feature property corresponds to a feature id .
|
||||||
@ -70,7 +70,7 @@ public interface FeaturePropertyDAO {
|
|||||||
* @return Feature property object that holds data of the feature property represented by propertyId.
|
* @return Feature property object that holds data of the feature property represented by propertyId.
|
||||||
* @throws MobileDeviceManagementDAOException
|
* @throws MobileDeviceManagementDAOException
|
||||||
*/
|
*/
|
||||||
List<FeatureProperty> getFeaturePropertyOfFeature(String featureId)
|
List<MobileFeatureProperty> getFeaturePropertyOfFeature(String featureId)
|
||||||
throws MobileDeviceManagementDAOException;
|
throws MobileDeviceManagementDAOException;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -19,7 +19,7 @@ package org.wso2.carbon.device.mgt.mobile.dao;
|
|||||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation;
|
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents the key operations associated with persisting operation related
|
* This class represents the key operations associated with persisting mobile operation related
|
||||||
* information.
|
* information.
|
||||||
*/
|
*/
|
||||||
public interface MobileOperationDAO {
|
public interface MobileOperationDAO {
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import org.wso2.carbon.device.mgt.mobile.dto.MobileOperationProperty;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents the key operations associated with persisting operation property related
|
* This class represents the key operations associated with persisting mobile operation property related
|
||||||
* information.
|
* information.
|
||||||
*/
|
*/
|
||||||
public interface MobileOperationPropertyDAO {
|
public interface MobileOperationPropertyDAO {
|
||||||
|
|||||||
@ -1,218 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015, 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.carbon.device.mgt.mobile.dao.impl;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceOperationDAO;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperation;
|
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of MobileDeviceOperationDAO.
|
|
||||||
*/
|
|
||||||
public class MobileDeviceOperationDAOImpl implements MobileDeviceOperationDAO {
|
|
||||||
|
|
||||||
private DataSource dataSource;
|
|
||||||
private static final Log log = LogFactory.getLog(MobileDeviceOperationDAOImpl.class);
|
|
||||||
|
|
||||||
public MobileDeviceOperationDAOImpl(DataSource dataSource) {
|
|
||||||
this.dataSource = dataSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean addMobileDeviceOperation(MobileDeviceOperation deviceOperation)
|
|
||||||
throws MobileDeviceManagementDAOException {
|
|
||||||
boolean status = false;
|
|
||||||
Connection conn = null;
|
|
||||||
PreparedStatement stmt = null;
|
|
||||||
try {
|
|
||||||
conn = this.getConnection();
|
|
||||||
String createDBQuery =
|
|
||||||
"INSERT INTO MBL_DEVICE_OPERATION(DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE) VALUES (?, ?, ?, ?)";
|
|
||||||
|
|
||||||
stmt = conn.prepareStatement(createDBQuery);
|
|
||||||
stmt.setString(1, deviceOperation.getDeviceId());
|
|
||||||
stmt.setLong(2, deviceOperation.getOperationId());
|
|
||||||
stmt.setLong(3, deviceOperation.getSentDate());
|
|
||||||
stmt.setLong(4, deviceOperation.getReceivedDate());
|
|
||||||
int rows = stmt.executeUpdate();
|
|
||||||
if (rows > 0) {
|
|
||||||
status = true;
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
String msg = "Error occurred while adding device id - '" +
|
|
||||||
deviceOperation.getDeviceId() + " and operation id - " +
|
|
||||||
deviceOperation.getOperationId() +
|
|
||||||
" to mapping table MBL_DEVICE_OPERATION";
|
|
||||||
;
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new MobileDeviceManagementDAOException(msg, e);
|
|
||||||
} finally {
|
|
||||||
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
|
||||||
}
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean updateMobileDeviceOperation(MobileDeviceOperation deviceOperation)
|
|
||||||
throws MobileDeviceManagementDAOException {
|
|
||||||
boolean status = false;
|
|
||||||
Connection conn = null;
|
|
||||||
PreparedStatement stmt = null;
|
|
||||||
try {
|
|
||||||
conn = this.getConnection();
|
|
||||||
String updateDBQuery =
|
|
||||||
"UPDATE MBL_DEVICE_OPERATION SET SENT_DATE = ?, RECEIVED_DATE = ? WHERE DEVICE_ID = ? AND OPERATION_ID=?";
|
|
||||||
stmt = conn.prepareStatement(updateDBQuery);
|
|
||||||
stmt.setLong(1, deviceOperation.getSentDate());
|
|
||||||
stmt.setLong(2, deviceOperation.getReceivedDate());
|
|
||||||
stmt.setString(3, deviceOperation.getDeviceId());
|
|
||||||
stmt.setInt(4, deviceOperation.getOperationId());
|
|
||||||
int rows = stmt.executeUpdate();
|
|
||||||
if (rows > 0) {
|
|
||||||
status = true;
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
String msg = "Error occurred while updating device id - '" +
|
|
||||||
deviceOperation.getDeviceId() + " and operation id - " +
|
|
||||||
deviceOperation.getOperationId() + " in table MBL_DEVICE_OPERATION";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new MobileDeviceManagementDAOException(msg, e);
|
|
||||||
} finally {
|
|
||||||
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
|
||||||
}
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean deleteMobileDeviceOperation(String deviceId, int operationId)
|
|
||||||
throws MobileDeviceManagementDAOException {
|
|
||||||
boolean status = false;
|
|
||||||
Connection conn = null;
|
|
||||||
PreparedStatement stmt = null;
|
|
||||||
try {
|
|
||||||
conn = this.getConnection();
|
|
||||||
String deleteDBQuery =
|
|
||||||
"DELETE FROM MBL_DEVICE_OPERATION WHERE DEVICE_ID = ? AND OPERATION_ID=?";
|
|
||||||
stmt = conn.prepareStatement(deleteDBQuery);
|
|
||||||
stmt.setString(1, deviceId);
|
|
||||||
stmt.setInt(2, operationId);
|
|
||||||
int rows = stmt.executeUpdate();
|
|
||||||
if (rows > 0) {
|
|
||||||
status = true;
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
String msg =
|
|
||||||
"Error occurred while deleting the table entry MBL_DEVICE_OPERATION with device id - '" +
|
|
||||||
deviceId + " and operation id - " + operationId;
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new MobileDeviceManagementDAOException(msg, e);
|
|
||||||
} finally {
|
|
||||||
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
|
||||||
}
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MobileDeviceOperation getMobileDeviceOperation(String deviceId, int operationId)
|
|
||||||
throws MobileDeviceManagementDAOException {
|
|
||||||
Connection conn = null;
|
|
||||||
PreparedStatement stmt = null;
|
|
||||||
MobileDeviceOperation deviceOperation = null;
|
|
||||||
try {
|
|
||||||
conn = this.getConnection();
|
|
||||||
String selectDBQuery =
|
|
||||||
"SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE FROM MBL_DEVICE_OPERATION WHERE DEVICE_ID = ? AND OPERATION_ID=?";
|
|
||||||
stmt = conn.prepareStatement(selectDBQuery);
|
|
||||||
stmt.setString(1, deviceId);
|
|
||||||
stmt.setInt(2, operationId);
|
|
||||||
ResultSet resultSet = stmt.executeQuery();
|
|
||||||
while (resultSet.next()) {
|
|
||||||
deviceOperation = new MobileDeviceOperation();
|
|
||||||
deviceOperation.setDeviceId(resultSet.getString(1));
|
|
||||||
deviceOperation.setOperationId(resultSet.getInt(2));
|
|
||||||
deviceOperation.setSentDate(resultSet.getInt(3));
|
|
||||||
deviceOperation.setReceivedDate(resultSet.getInt(4));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
String msg =
|
|
||||||
"Error occurred while fetching table MBL_DEVICE_OPERATION entry with device id - '" +
|
|
||||||
deviceId + " and operation id - " + operationId;
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new MobileDeviceManagementDAOException(msg, e);
|
|
||||||
} finally {
|
|
||||||
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
|
||||||
}
|
|
||||||
return deviceOperation;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<MobileDeviceOperation> getAllMobileDeviceOperationsOfDevice(String deviceId)
|
|
||||||
throws MobileDeviceManagementDAOException {
|
|
||||||
Connection conn = null;
|
|
||||||
PreparedStatement stmt = null;
|
|
||||||
MobileDeviceOperation deviceOperation = null;
|
|
||||||
List<MobileDeviceOperation> deviceOperations = new ArrayList<MobileDeviceOperation>();
|
|
||||||
try {
|
|
||||||
conn = this.getConnection();
|
|
||||||
String selectDBQuery =
|
|
||||||
"SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE FROM MBL_DEVICE_OPERATION WHERE DEVICE_ID = ?";
|
|
||||||
stmt = conn.prepareStatement(selectDBQuery);
|
|
||||||
stmt.setString(1, deviceId);
|
|
||||||
ResultSet resultSet = stmt.executeQuery();
|
|
||||||
while (resultSet.next()) {
|
|
||||||
deviceOperation = new MobileDeviceOperation();
|
|
||||||
deviceOperation.setDeviceId(resultSet.getString(1));
|
|
||||||
deviceOperation.setOperationId(resultSet.getInt(2));
|
|
||||||
deviceOperation.setSentDate(resultSet.getInt(3));
|
|
||||||
deviceOperation.setReceivedDate(resultSet.getInt(4));
|
|
||||||
deviceOperations.add(deviceOperation);
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
String msg =
|
|
||||||
"Error occurred while fetching mapping table MBL_DEVICE_OPERATION entries of device id - '" +
|
|
||||||
deviceId;
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new MobileDeviceManagementDAOException(msg, e);
|
|
||||||
} finally {
|
|
||||||
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
|
||||||
}
|
|
||||||
return deviceOperations;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Connection getConnection() throws MobileDeviceManagementDAOException {
|
|
||||||
try {
|
|
||||||
return dataSource.getConnection();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
String msg = "Error occurred while obtaining a connection from the mobile device " +
|
|
||||||
"management metadata repository datasource.";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new MobileDeviceManagementDAOException(msg, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,331 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, 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.carbon.device.mgt.mobile.dao.impl;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceOperationMappingDAO;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperationMapping;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of MobileDeviceOperationMappingDAO.
|
||||||
|
*/
|
||||||
|
public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperationMappingDAO {
|
||||||
|
|
||||||
|
private DataSource dataSource;
|
||||||
|
private static final Log log = LogFactory.getLog(MobileDeviceOperationMappingDAOImpl.class);
|
||||||
|
|
||||||
|
public MobileDeviceOperationMappingDAOImpl(DataSource dataSource) {
|
||||||
|
this.dataSource = dataSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addMobileDeviceOperation(MobileDeviceOperationMapping deviceOperation)
|
||||||
|
throws MobileDeviceManagementDAOException {
|
||||||
|
boolean status = false;
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String createDBQuery =
|
||||||
|
"INSERT INTO MBL_DEVICE_OPERATION_MAPPING (DEVICE_ID, OPERATION_ID, SENT_DATE, " +
|
||||||
|
"RECEIVED_DATE, STATUS) VALUES (?, ?, ?, ?, ?)";
|
||||||
|
|
||||||
|
stmt = conn.prepareStatement(createDBQuery);
|
||||||
|
stmt.setString(1, deviceOperation.getDeviceId());
|
||||||
|
stmt.setLong(2, deviceOperation.getOperationId());
|
||||||
|
stmt.setLong(3, deviceOperation.getSentDate());
|
||||||
|
stmt.setLong(4, deviceOperation.getReceivedDate());
|
||||||
|
stmt.setString(5, deviceOperation.getStatus().name());
|
||||||
|
int rows = stmt.executeUpdate();
|
||||||
|
if (rows > 0) {
|
||||||
|
status = true;
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
String msg = "Error occurred while adding device id - '" +
|
||||||
|
deviceOperation.getDeviceId() + " and operation id - " +
|
||||||
|
deviceOperation.getOperationId() +
|
||||||
|
" to mapping table MBL_DEVICE_OPERATION";
|
||||||
|
;
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new MobileDeviceManagementDAOException(msg, e);
|
||||||
|
} finally {
|
||||||
|
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean updateMobileDeviceOperation(MobileDeviceOperationMapping deviceOperation)
|
||||||
|
throws MobileDeviceManagementDAOException {
|
||||||
|
boolean status = false;
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String updateDBQuery =
|
||||||
|
"UPDATE MBL_DEVICE_OPERATION_MAPPING SET SENT_DATE = ?, RECEIVED_DATE = ?, STATUS = ? " +
|
||||||
|
"WHERE DEVICE_ID = ? AND OPERATION_ID=?";
|
||||||
|
stmt = conn.prepareStatement(updateDBQuery);
|
||||||
|
stmt.setLong(1, deviceOperation.getSentDate());
|
||||||
|
stmt.setLong(2, deviceOperation.getReceivedDate());
|
||||||
|
stmt.setString(3, deviceOperation.getStatus().name());
|
||||||
|
stmt.setString(4, deviceOperation.getDeviceId());
|
||||||
|
stmt.setInt(5, deviceOperation.getOperationId());
|
||||||
|
int rows = stmt.executeUpdate();
|
||||||
|
if (rows > 0) {
|
||||||
|
status = true;
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
String msg = "Error occurred while updating device id - '" +
|
||||||
|
deviceOperation.getDeviceId() + " and operation id - " +
|
||||||
|
deviceOperation.getOperationId() + " in table MBL_DEVICE_OPERATION";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new MobileDeviceManagementDAOException(msg, e);
|
||||||
|
} finally {
|
||||||
|
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean updateMobileDeviceOperationToInProgress(String deviceId, int operationId)
|
||||||
|
throws MobileDeviceManagementDAOException {
|
||||||
|
boolean status = false;
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String updateDBQuery =
|
||||||
|
"UPDATE MBL_DEVICE_OPERATION_MAPPING SET SENT_DATE = ?, STATUS = ? " +
|
||||||
|
"WHERE DEVICE_ID = ? AND OPERATION_ID=?";
|
||||||
|
stmt = conn.prepareStatement(updateDBQuery);
|
||||||
|
stmt.setLong(1, new Date().getTime());
|
||||||
|
stmt.setString(2, MobileDeviceOperationMapping.Status.INPROGRESS.name());
|
||||||
|
stmt.setString(3, deviceId);
|
||||||
|
stmt.setInt(4, operationId);
|
||||||
|
int rows = stmt.executeUpdate();
|
||||||
|
if (rows > 0) {
|
||||||
|
status = true;
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
String msg =
|
||||||
|
"Error occurred while updating the Status of operation to in-progress of device id - '" +
|
||||||
|
deviceId + " and operation id - " +
|
||||||
|
operationId + " in table MBL_DEVICE_OPERATION";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new MobileDeviceManagementDAOException(msg, e);
|
||||||
|
} finally {
|
||||||
|
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean updateMobileDeviceOperationToCompleted(String deviceId,
|
||||||
|
int operationId)
|
||||||
|
throws MobileDeviceManagementDAOException {
|
||||||
|
boolean status = false;
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String updateDBQuery =
|
||||||
|
"UPDATE MBL_DEVICE_OPERATION_MAPPING SET RECEIVED_DATE = ?, STATUS = ? " +
|
||||||
|
"WHERE DEVICE_ID = ? AND OPERATION_ID=?";
|
||||||
|
stmt = conn.prepareStatement(updateDBQuery);
|
||||||
|
stmt.setLong(1, new Date().getTime());
|
||||||
|
stmt.setString(2, MobileDeviceOperationMapping.Status.COMPLETED.name());
|
||||||
|
stmt.setString(3, deviceId);
|
||||||
|
stmt.setInt(4, operationId);
|
||||||
|
int rows = stmt.executeUpdate();
|
||||||
|
if (rows > 0) {
|
||||||
|
status = true;
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
String msg =
|
||||||
|
"Error occurred while updating the Status of operation to completed of device id - '" +
|
||||||
|
deviceId + " and operation id - " +
|
||||||
|
operationId + " in table MBL_DEVICE_OPERATION";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new MobileDeviceManagementDAOException(msg, e);
|
||||||
|
} finally {
|
||||||
|
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteMobileDeviceOperation(String deviceId, int operationId)
|
||||||
|
throws MobileDeviceManagementDAOException {
|
||||||
|
boolean status = false;
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String deleteDBQuery =
|
||||||
|
"DELETE FROM MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID=?";
|
||||||
|
stmt = conn.prepareStatement(deleteDBQuery);
|
||||||
|
stmt.setString(1, deviceId);
|
||||||
|
stmt.setInt(2, operationId);
|
||||||
|
int rows = stmt.executeUpdate();
|
||||||
|
if (rows > 0) {
|
||||||
|
status = true;
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
String msg =
|
||||||
|
"Error occurred while deleting the table entry MBL_DEVICE_OPERATION with " +
|
||||||
|
" device id - '" + deviceId + " and operation id - " + operationId;
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new MobileDeviceManagementDAOException(msg, e);
|
||||||
|
} finally {
|
||||||
|
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MobileDeviceOperationMapping getMobileDeviceOperation(String deviceId, int operationId)
|
||||||
|
throws MobileDeviceManagementDAOException {
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
MobileDeviceOperationMapping mblDeviceOperation = null;
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String selectDBQuery =
|
||||||
|
"SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE, STATUS FROM " +
|
||||||
|
"MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID=?";
|
||||||
|
stmt = conn.prepareStatement(selectDBQuery);
|
||||||
|
stmt.setString(1, deviceId);
|
||||||
|
stmt.setInt(2, operationId);
|
||||||
|
ResultSet resultSet = stmt.executeQuery();
|
||||||
|
while (resultSet.next()) {
|
||||||
|
mblDeviceOperation = new MobileDeviceOperationMapping();
|
||||||
|
mblDeviceOperation.setDeviceId(resultSet.getString(1));
|
||||||
|
mblDeviceOperation.setOperationId(resultSet.getInt(2));
|
||||||
|
mblDeviceOperation.setSentDate(resultSet.getInt(3));
|
||||||
|
mblDeviceOperation.setReceivedDate(resultSet.getInt(4));
|
||||||
|
mblDeviceOperation.setStatus(resultSet.getString(5));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
String msg =
|
||||||
|
"Error occurred while fetching table MBL_DEVICE_OPERATION entry with device id - '" +
|
||||||
|
deviceId + " and operation id - " + operationId;
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new MobileDeviceManagementDAOException(msg, e);
|
||||||
|
} finally {
|
||||||
|
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||||
|
}
|
||||||
|
return mblDeviceOperation;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MobileDeviceOperationMapping> getAllMobileDeviceOperationsOfDevice(String deviceId)
|
||||||
|
throws MobileDeviceManagementDAOException {
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
MobileDeviceOperationMapping mblDeviceOperation = null;
|
||||||
|
List<MobileDeviceOperationMapping> mblDeviceOperations = new ArrayList<MobileDeviceOperationMapping>();
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String selectDBQuery =
|
||||||
|
"SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE, STATUS FROM " +
|
||||||
|
"MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ?";
|
||||||
|
stmt = conn.prepareStatement(selectDBQuery);
|
||||||
|
stmt.setString(1, deviceId);
|
||||||
|
ResultSet resultSet = stmt.executeQuery();
|
||||||
|
while (resultSet.next()) {
|
||||||
|
mblDeviceOperation = new MobileDeviceOperationMapping();
|
||||||
|
mblDeviceOperation.setDeviceId(resultSet.getString(1));
|
||||||
|
mblDeviceOperation.setOperationId(resultSet.getInt(2));
|
||||||
|
mblDeviceOperation.setSentDate(resultSet.getInt(3));
|
||||||
|
mblDeviceOperation.setReceivedDate(resultSet.getInt(4));
|
||||||
|
mblDeviceOperation.setStatus(resultSet.getString(5));
|
||||||
|
mblDeviceOperations.add(mblDeviceOperation);
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
String msg =
|
||||||
|
"Error occurred while fetching mapping table MBL_DEVICE_OPERATION entries of " +
|
||||||
|
"device id - '" + deviceId;
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new MobileDeviceManagementDAOException(msg, e);
|
||||||
|
} finally {
|
||||||
|
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||||
|
}
|
||||||
|
return mblDeviceOperations;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MobileDeviceOperationMapping> getAllPendingOperationsOfMobileDevice(String deviceId)
|
||||||
|
throws MobileDeviceManagementDAOException {
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
MobileDeviceOperationMapping mblDeviceOperation = null;
|
||||||
|
List<MobileDeviceOperationMapping> mblDeviceOperations = new ArrayList<MobileDeviceOperationMapping>();
|
||||||
|
try {
|
||||||
|
|
||||||
|
conn = this.getConnection();
|
||||||
|
String selectDBQuery =
|
||||||
|
"SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE, STATUS FROM" +
|
||||||
|
" MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND STATUS = 'NEW'";
|
||||||
|
stmt = conn.prepareStatement(selectDBQuery);
|
||||||
|
stmt.setString(1, deviceId);
|
||||||
|
ResultSet resultSet = stmt.executeQuery();
|
||||||
|
while (resultSet.next()) {
|
||||||
|
mblDeviceOperation = new MobileDeviceOperationMapping();
|
||||||
|
mblDeviceOperation.setDeviceId(resultSet.getString(1));
|
||||||
|
mblDeviceOperation.setOperationId(resultSet.getInt(2));
|
||||||
|
mblDeviceOperation.setSentDate(resultSet.getInt(3));
|
||||||
|
mblDeviceOperation.setReceivedDate(resultSet.getInt(4));
|
||||||
|
mblDeviceOperation.setStatus(resultSet.getString(5));
|
||||||
|
mblDeviceOperations.add(mblDeviceOperation);
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
String msg =
|
||||||
|
"Error occurred while fetching mapping table MBL_DEVICE_OPERATION entries of" +
|
||||||
|
" device id - '" + deviceId;
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new MobileDeviceManagementDAOException(msg, e);
|
||||||
|
} finally {
|
||||||
|
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||||
|
}
|
||||||
|
return mblDeviceOperations;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Connection getConnection() throws MobileDeviceManagementDAOException {
|
||||||
|
try {
|
||||||
|
return dataSource.getConnection();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
String msg = "Error occurred while obtaining a connection from the mobile device " +
|
||||||
|
"management metadata repository datasource.";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new MobileDeviceManagementDAOException(msg, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -18,10 +18,10 @@ package org.wso2.carbon.device.mgt.mobile.dao.impl;
|
|||||||
|
|
||||||
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.mobile.dao.FeatureDAO;
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileFeatureDAO;
|
||||||
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
||||||
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
|
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
|
||||||
import org.wso2.carbon.device.mgt.mobile.dto.Feature;
|
import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@ -32,19 +32,19 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of FeatureDAO.
|
* Implementation of MobileFeatureDAO.
|
||||||
*/
|
*/
|
||||||
public class FeatureDAOImpl implements FeatureDAO {
|
public class MobileFeatureDAOImpl implements MobileFeatureDAO {
|
||||||
|
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
private static final Log log = LogFactory.getLog(FeatureDAOImpl.class);
|
private static final Log log = LogFactory.getLog(MobileFeatureDAOImpl.class);
|
||||||
|
|
||||||
public FeatureDAOImpl(DataSource dataSource) {
|
public MobileFeatureDAOImpl(DataSource dataSource) {
|
||||||
this.dataSource = dataSource;
|
this.dataSource = dataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addFeature(Feature feature) throws MobileDeviceManagementDAOException {
|
public boolean addFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException {
|
||||||
boolean status = false;
|
boolean status = false;
|
||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
@ -54,16 +54,16 @@ public class FeatureDAOImpl implements FeatureDAO {
|
|||||||
"INSERT INTO MBL_FEATURE(CODE, NAME, DESCRIPTION) VALUES (?, ?, ?)";
|
"INSERT INTO MBL_FEATURE(CODE, NAME, DESCRIPTION) VALUES (?, ?, ?)";
|
||||||
|
|
||||||
stmt = conn.prepareStatement(createDBQuery);
|
stmt = conn.prepareStatement(createDBQuery);
|
||||||
stmt.setString(1, feature.getCode());
|
stmt.setString(1, mobileFeature.getCode());
|
||||||
stmt.setString(2, feature.getName());
|
stmt.setString(2, mobileFeature.getName());
|
||||||
stmt.setString(3, feature.getDescription());
|
stmt.setString(3, mobileFeature.getDescription());
|
||||||
int rows = stmt.executeUpdate();
|
int rows = stmt.executeUpdate();
|
||||||
if (rows > 0) {
|
if (rows > 0) {
|
||||||
status = true;
|
status = true;
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
String msg = "Error occurred while adding feature code - '" +
|
String msg = "Error occurred while adding feature code - '" +
|
||||||
feature.getCode() + "' to feature table";
|
mobileFeature.getCode() + "' to feature table";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new MobileDeviceManagementDAOException(msg, e);
|
throw new MobileDeviceManagementDAOException(msg, e);
|
||||||
} finally {
|
} finally {
|
||||||
@ -73,7 +73,7 @@ public class FeatureDAOImpl implements FeatureDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateFeature(Feature feature)
|
public boolean updateFeature(MobileFeature mobileFeature)
|
||||||
throws MobileDeviceManagementDAOException {
|
throws MobileDeviceManagementDAOException {
|
||||||
boolean status = false;
|
boolean status = false;
|
||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
@ -83,17 +83,17 @@ public class FeatureDAOImpl implements FeatureDAO {
|
|||||||
String updateDBQuery =
|
String updateDBQuery =
|
||||||
"UPDATE MBL_FEATURE SET CODE = ?, NAME = ?, DESCRIPTION = ? WHERE FEATURE_ID = ?";
|
"UPDATE MBL_FEATURE SET CODE = ?, NAME = ?, DESCRIPTION = ? WHERE FEATURE_ID = ?";
|
||||||
stmt = conn.prepareStatement(updateDBQuery);
|
stmt = conn.prepareStatement(updateDBQuery);
|
||||||
stmt.setString(1, feature.getCode());
|
stmt.setString(1, mobileFeature.getCode());
|
||||||
stmt.setString(2, feature.getName());
|
stmt.setString(2, mobileFeature.getName());
|
||||||
stmt.setString(3, feature.getDescription());
|
stmt.setString(3, mobileFeature.getDescription());
|
||||||
stmt.setInt(4, feature.getId());
|
stmt.setInt(4, mobileFeature.getId());
|
||||||
int rows = stmt.executeUpdate();
|
int rows = stmt.executeUpdate();
|
||||||
if (rows > 0) {
|
if (rows > 0) {
|
||||||
status = true;
|
status = true;
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
String msg = "Error occurred while updating the feature with feature code - '" +
|
String msg = "Error occurred while updating the feature with feature code - '" +
|
||||||
feature.getId() + "'";
|
mobileFeature.getId() + "'";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new MobileDeviceManagementDAOException(msg, e);
|
throw new MobileDeviceManagementDAOException(msg, e);
|
||||||
} finally {
|
} finally {
|
||||||
@ -155,11 +155,11 @@ public class FeatureDAOImpl implements FeatureDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Feature getFeatureByCode(String featureCode)
|
public MobileFeature getFeatureByCode(String featureCode)
|
||||||
throws MobileDeviceManagementDAOException {
|
throws MobileDeviceManagementDAOException {
|
||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
Feature feature = null;
|
MobileFeature mobileFeature = null;
|
||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
String selectDBQuery =
|
String selectDBQuery =
|
||||||
@ -168,11 +168,11 @@ public class FeatureDAOImpl implements FeatureDAO {
|
|||||||
stmt.setString(1, featureCode);
|
stmt.setString(1, featureCode);
|
||||||
ResultSet resultSet = stmt.executeQuery();
|
ResultSet resultSet = stmt.executeQuery();
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
feature = new Feature();
|
mobileFeature = new MobileFeature();
|
||||||
feature.setId(resultSet.getInt(1));
|
mobileFeature.setId(resultSet.getInt(1));
|
||||||
feature.setCode(resultSet.getString(2));
|
mobileFeature.setCode(resultSet.getString(2));
|
||||||
feature.setName(resultSet.getString(3));
|
mobileFeature.setName(resultSet.getString(3));
|
||||||
feature.setDescription(resultSet.getString(4));
|
mobileFeature.setDescription(resultSet.getString(4));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -183,15 +183,15 @@ public class FeatureDAOImpl implements FeatureDAO {
|
|||||||
} finally {
|
} finally {
|
||||||
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||||
}
|
}
|
||||||
return feature;
|
return mobileFeature;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Feature getFeatureById(String featureID)
|
public MobileFeature getFeatureById(String featureID)
|
||||||
throws MobileDeviceManagementDAOException {
|
throws MobileDeviceManagementDAOException {
|
||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
Feature feature = null;
|
MobileFeature mobileFeature = null;
|
||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
String selectDBQuery =
|
String selectDBQuery =
|
||||||
@ -200,11 +200,11 @@ public class FeatureDAOImpl implements FeatureDAO {
|
|||||||
stmt.setString(1, featureID);
|
stmt.setString(1, featureID);
|
||||||
ResultSet resultSet = stmt.executeQuery();
|
ResultSet resultSet = stmt.executeQuery();
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
feature = new Feature();
|
mobileFeature = new MobileFeature();
|
||||||
feature.setId(resultSet.getInt(1));
|
mobileFeature.setId(resultSet.getInt(1));
|
||||||
feature.setCode(resultSet.getString(2));
|
mobileFeature.setCode(resultSet.getString(2));
|
||||||
feature.setName(resultSet.getString(3));
|
mobileFeature.setName(resultSet.getString(3));
|
||||||
feature.setDescription(resultSet.getString(4));
|
mobileFeature.setDescription(resultSet.getString(4));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -215,15 +215,15 @@ public class FeatureDAOImpl implements FeatureDAO {
|
|||||||
} finally {
|
} finally {
|
||||||
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||||
}
|
}
|
||||||
return feature;
|
return mobileFeature;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Feature> getAllFeatures() throws MobileDeviceManagementDAOException {
|
public List<MobileFeature> getAllFeatures() throws MobileDeviceManagementDAOException {
|
||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
Feature feature;
|
MobileFeature mobileFeature;
|
||||||
List<Feature> features = new ArrayList<Feature>();
|
List<MobileFeature> mobileFeatures = new ArrayList<MobileFeature>();
|
||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
String selectDBQuery =
|
String selectDBQuery =
|
||||||
@ -231,14 +231,14 @@ public class FeatureDAOImpl implements FeatureDAO {
|
|||||||
stmt = conn.prepareStatement(selectDBQuery);
|
stmt = conn.prepareStatement(selectDBQuery);
|
||||||
ResultSet resultSet = stmt.executeQuery();
|
ResultSet resultSet = stmt.executeQuery();
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
feature = new Feature();
|
mobileFeature = new MobileFeature();
|
||||||
feature.setId(resultSet.getInt(1));
|
mobileFeature.setId(resultSet.getInt(1));
|
||||||
feature.setCode(resultSet.getString(2));
|
mobileFeature.setCode(resultSet.getString(2));
|
||||||
feature.setName(resultSet.getString(3));
|
mobileFeature.setName(resultSet.getString(3));
|
||||||
feature.setDescription(resultSet.getString(4));
|
mobileFeature.setDescription(resultSet.getString(4));
|
||||||
features.add(feature);
|
mobileFeatures.add(mobileFeature);
|
||||||
}
|
}
|
||||||
return features;
|
return mobileFeatures;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
String msg = "Error occurred while fetching all features.'";
|
String msg = "Error occurred while fetching all features.'";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
@ -18,10 +18,10 @@ package org.wso2.carbon.device.mgt.mobile.dao.impl;
|
|||||||
|
|
||||||
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.mobile.dao.FeaturePropertyDAO;
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileFeaturePropertyDAO;
|
||||||
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
||||||
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
|
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
|
||||||
import org.wso2.carbon.device.mgt.mobile.dto.FeatureProperty;
|
import org.wso2.carbon.device.mgt.mobile.dto.MobileFeatureProperty;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@ -32,19 +32,19 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of FeaturePropertyDAO.
|
* Implementation of MobileFeaturePropertyDAO.
|
||||||
*/
|
*/
|
||||||
public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
|
public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO {
|
||||||
|
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
private static final Log log = LogFactory.getLog(FeaturePropertyDAOImpl.class);
|
private static final Log log = LogFactory.getLog(MobileFeaturePropertyDAOImpl.class);
|
||||||
|
|
||||||
public FeaturePropertyDAOImpl(DataSource dataSource) {
|
public MobileFeaturePropertyDAOImpl(DataSource dataSource) {
|
||||||
this.dataSource = dataSource;
|
this.dataSource = dataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addFeatureProperty(FeatureProperty featureProperty)
|
public boolean addFeatureProperty(MobileFeatureProperty mobileFeatureProperty)
|
||||||
throws MobileDeviceManagementDAOException {
|
throws MobileDeviceManagementDAOException {
|
||||||
boolean status = false;
|
boolean status = false;
|
||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
@ -55,15 +55,15 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
|
|||||||
"INSERT INTO MBL_FEATURE_PROPERTY(PROPERTY, FEATURE_ID) VALUES (?, ?)";
|
"INSERT INTO MBL_FEATURE_PROPERTY(PROPERTY, FEATURE_ID) VALUES (?, ?)";
|
||||||
|
|
||||||
stmt = conn.prepareStatement(createDBQuery);
|
stmt = conn.prepareStatement(createDBQuery);
|
||||||
stmt.setString(1, featureProperty.getProperty());
|
stmt.setString(1, mobileFeatureProperty.getProperty());
|
||||||
stmt.setString(2, featureProperty.getFeatureID());
|
stmt.setString(2, mobileFeatureProperty.getFeatureID());
|
||||||
int rows = stmt.executeUpdate();
|
int rows = stmt.executeUpdate();
|
||||||
if (rows > 0) {
|
if (rows > 0) {
|
||||||
status = true;
|
status = true;
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
String msg = "Error occurred while adding property id - '" +
|
String msg = "Error occurred while adding property id - '" +
|
||||||
featureProperty.getFeatureID() + "'";
|
mobileFeatureProperty.getFeatureID() + "'";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new MobileDeviceManagementDAOException(msg, e);
|
throw new MobileDeviceManagementDAOException(msg, e);
|
||||||
} finally {
|
} finally {
|
||||||
@ -73,7 +73,7 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateFeatureProperty(FeatureProperty featureProperty)
|
public boolean updateFeatureProperty(MobileFeatureProperty mobileFeatureProperty)
|
||||||
throws MobileDeviceManagementDAOException {
|
throws MobileDeviceManagementDAOException {
|
||||||
boolean status = false;
|
boolean status = false;
|
||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
@ -83,15 +83,15 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
|
|||||||
String updateDBQuery =
|
String updateDBQuery =
|
||||||
"UPDATE MBL_FEATURE_PROPERTY SET FEATURE_ID = ? WHERE PROPERTY = ?";
|
"UPDATE MBL_FEATURE_PROPERTY SET FEATURE_ID = ? WHERE PROPERTY = ?";
|
||||||
stmt = conn.prepareStatement(updateDBQuery);
|
stmt = conn.prepareStatement(updateDBQuery);
|
||||||
stmt.setString(1, featureProperty.getFeatureID());
|
stmt.setString(1, mobileFeatureProperty.getFeatureID());
|
||||||
stmt.setString(2, featureProperty.getProperty());
|
stmt.setString(2, mobileFeatureProperty.getProperty());
|
||||||
int rows = stmt.executeUpdate();
|
int rows = stmt.executeUpdate();
|
||||||
if (rows > 0) {
|
if (rows > 0) {
|
||||||
status = true;
|
status = true;
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
String msg = "Error occurred while updating the feature property with property - '" +
|
String msg = "Error occurred while updating the feature property with property - '" +
|
||||||
featureProperty.getProperty() + "'";
|
mobileFeatureProperty.getProperty() + "'";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new MobileDeviceManagementDAOException(msg, e);
|
throw new MobileDeviceManagementDAOException(msg, e);
|
||||||
} finally {
|
} finally {
|
||||||
@ -128,11 +128,11 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FeatureProperty getFeatureProperty(String property)
|
public MobileFeatureProperty getFeatureProperty(String property)
|
||||||
throws MobileDeviceManagementDAOException {
|
throws MobileDeviceManagementDAOException {
|
||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
FeatureProperty featureProperty = null;
|
MobileFeatureProperty mobileFeatureProperty = null;
|
||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
String selectDBQuery =
|
String selectDBQuery =
|
||||||
@ -141,9 +141,9 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
|
|||||||
stmt.setString(1, property);
|
stmt.setString(1, property);
|
||||||
ResultSet resultSet = stmt.executeQuery();
|
ResultSet resultSet = stmt.executeQuery();
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
featureProperty = new FeatureProperty();
|
mobileFeatureProperty = new MobileFeatureProperty();
|
||||||
featureProperty.setProperty(resultSet.getString(1));
|
mobileFeatureProperty.setProperty(resultSet.getString(1));
|
||||||
featureProperty.setFeatureID(resultSet.getString(2));
|
mobileFeatureProperty.setFeatureID(resultSet.getString(2));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -154,16 +154,16 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
|
|||||||
} finally {
|
} finally {
|
||||||
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||||
}
|
}
|
||||||
return featureProperty;
|
return mobileFeatureProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FeatureProperty> getFeaturePropertyOfFeature(String featureId)
|
public List<MobileFeatureProperty> getFeaturePropertyOfFeature(String featureId)
|
||||||
throws MobileDeviceManagementDAOException {
|
throws MobileDeviceManagementDAOException {
|
||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
FeatureProperty featureProperty = null;
|
MobileFeatureProperty mobileFeatureProperty = null;
|
||||||
List<FeatureProperty> FeatureProperties = new ArrayList<FeatureProperty>();
|
List<MobileFeatureProperty> FeatureProperties = new ArrayList<MobileFeatureProperty>();
|
||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
String selectDBQuery =
|
String selectDBQuery =
|
||||||
@ -172,10 +172,10 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
|
|||||||
stmt.setString(1, featureId);
|
stmt.setString(1, featureId);
|
||||||
ResultSet resultSet = stmt.executeQuery();
|
ResultSet resultSet = stmt.executeQuery();
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
featureProperty = new FeatureProperty();
|
mobileFeatureProperty = new MobileFeatureProperty();
|
||||||
featureProperty.setProperty(resultSet.getString(1));
|
mobileFeatureProperty.setProperty(resultSet.getString(1));
|
||||||
featureProperty.setFeatureID(resultSet.getString(2));
|
mobileFeatureProperty.setFeatureID(resultSet.getString(2));
|
||||||
FeatureProperties.add(featureProperty);
|
FeatureProperties.add(mobileFeatureProperty);
|
||||||
}
|
}
|
||||||
return FeatureProperties;
|
return FeatureProperties;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -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.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -17,14 +17,37 @@
|
|||||||
package org.wso2.carbon.device.mgt.mobile.dto;
|
package org.wso2.carbon.device.mgt.mobile.dto;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DTO of Mobile Device Operations.
|
* DTO of Mobile Device Operation Mappings.
|
||||||
*/
|
*/
|
||||||
public class MobileDeviceOperation {
|
public class MobileDeviceOperationMapping {
|
||||||
|
|
||||||
private String deviceId;
|
private String deviceId;
|
||||||
private int operationId;
|
private int operationId;
|
||||||
private long sentDate;
|
private long sentDate;
|
||||||
private long receivedDate;
|
private long receivedDate;
|
||||||
|
private Status status;
|
||||||
|
|
||||||
|
public enum Status {
|
||||||
|
NEW, INPROGRESS, COMPLETED
|
||||||
|
}
|
||||||
|
|
||||||
|
public Status getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(Status status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
if(Status.NEW.name().equals(status)){
|
||||||
|
this.status = Status.NEW;
|
||||||
|
}else if(Status.INPROGRESS.name().equals(status)){
|
||||||
|
this.status = Status.INPROGRESS;
|
||||||
|
}else if(Status.COMPLETED.name().equals(status)){
|
||||||
|
this.status = Status.COMPLETED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getDeviceId() {
|
public String getDeviceId() {
|
||||||
return deviceId;
|
return deviceId;
|
||||||
@ -19,9 +19,9 @@ package org.wso2.carbon.device.mgt.mobile.dto;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DTO of features.
|
* DTO of Mobile features.
|
||||||
*/
|
*/
|
||||||
public class Feature implements Serializable {
|
public class MobileFeature implements Serializable {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private String code;
|
private String code;
|
||||||
@ -17,9 +17,9 @@
|
|||||||
package org.wso2.carbon.device.mgt.mobile.dto;
|
package org.wso2.carbon.device.mgt.mobile.dto;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DTO of feature property. Represents a property of a feature.
|
* DTO of Mobile feature property. Represents a property of a mobile feature.
|
||||||
*/
|
*/
|
||||||
public class FeatureProperty {
|
public class MobileFeatureProperty {
|
||||||
|
|
||||||
private String property;
|
private String property;
|
||||||
private String featureID;
|
private String featureID;
|
||||||
@ -23,12 +23,13 @@ import org.wso2.carbon.device.mgt.common.OperationManagementException;
|
|||||||
import org.wso2.carbon.device.mgt.mobile.AbstractMobileOperationManager;
|
import org.wso2.carbon.device.mgt.mobile.AbstractMobileOperationManager;
|
||||||
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
||||||
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory;
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory;
|
||||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperation;
|
import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperationMapping;
|
||||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation;
|
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation;
|
||||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperationProperty;
|
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperationProperty;
|
||||||
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
|
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class AndroidMobileOperationManager extends AbstractMobileOperationManager {
|
public class AndroidMobileOperationManager extends AbstractMobileOperationManager {
|
||||||
@ -40,7 +41,7 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage
|
|||||||
OperationManagementException {
|
OperationManagementException {
|
||||||
boolean status = false;
|
boolean status = false;
|
||||||
try {
|
try {
|
||||||
MobileDeviceOperation mobileDeviceOperation = null;
|
MobileDeviceOperationMapping mobileDeviceOperationMapping = null;
|
||||||
MobileOperation mobileOperation =
|
MobileOperation mobileOperation =
|
||||||
MobileDeviceManagementUtil.convertToMobileOperation(operation);
|
MobileDeviceManagementUtil.convertToMobileOperation(operation);
|
||||||
int operationId = MobileDeviceManagementDAOFactory.getMobileOperationDAO()
|
int operationId = MobileDeviceManagementDAOFactory.getMobileOperationDAO()
|
||||||
@ -53,12 +54,13 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage
|
|||||||
operationProperty);
|
operationProperty);
|
||||||
}
|
}
|
||||||
for (DeviceIdentifier deviceIdentifier : devices) {
|
for (DeviceIdentifier deviceIdentifier : devices) {
|
||||||
mobileDeviceOperation = new MobileDeviceOperation();
|
mobileDeviceOperationMapping = new MobileDeviceOperationMapping();
|
||||||
mobileDeviceOperation.setOperationId(operationId);
|
mobileDeviceOperationMapping.setOperationId(operationId);
|
||||||
mobileDeviceOperation.setDeviceId(deviceIdentifier.getId());
|
mobileDeviceOperationMapping.setDeviceId(deviceIdentifier.getId());
|
||||||
|
mobileDeviceOperationMapping.setStatus(MobileDeviceOperationMapping.Status.NEW);
|
||||||
status = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO()
|
status = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO()
|
||||||
.addMobileDeviceOperation(
|
.addMobileDeviceOperation(
|
||||||
new MobileDeviceOperation());
|
mobileDeviceOperationMapping);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (MobileDeviceManagementDAOException e) {
|
} catch (MobileDeviceManagementDAOException e) {
|
||||||
@ -74,20 +76,27 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage
|
|||||||
public List<Operation> getOperations(DeviceIdentifier deviceIdentifier)
|
public List<Operation> getOperations(DeviceIdentifier deviceIdentifier)
|
||||||
throws OperationManagementException {
|
throws OperationManagementException {
|
||||||
List<Operation> operations = new ArrayList<Operation>();
|
List<Operation> operations = new ArrayList<Operation>();
|
||||||
List<MobileDeviceOperation> mobileDeviceOperations = null;
|
List<MobileDeviceOperationMapping> mobileDeviceOperationMappings = null;
|
||||||
|
List<MobileOperationProperty> operationProperties = null;
|
||||||
MobileOperation mobileOperation = null;
|
MobileOperation mobileOperation = null;
|
||||||
try {
|
try {
|
||||||
mobileDeviceOperations = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO()
|
mobileDeviceOperationMappings = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO()
|
||||||
.getAllMobileDeviceOperationsOfDevice(
|
.getAllMobileDeviceOperationsOfDevice(
|
||||||
deviceIdentifier
|
deviceIdentifier
|
||||||
.getId());
|
.getId());
|
||||||
if (mobileDeviceOperations.size() > 0) {
|
if (mobileDeviceOperationMappings.size() > 0) {
|
||||||
List<Integer> operationIds = MobileDeviceManagementUtil
|
List<Integer> operationIds = MobileDeviceManagementUtil
|
||||||
.getMobileOperationIdsFromMobileDeviceOperations(mobileDeviceOperations);
|
.getMobileOperationIdsFromMobileDeviceOperations(
|
||||||
|
mobileDeviceOperationMappings);
|
||||||
for (Integer operationId : operationIds) {
|
for (Integer operationId : operationIds) {
|
||||||
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));
|
||||||
}
|
}
|
||||||
@ -101,4 +110,49 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage
|
|||||||
}
|
}
|
||||||
return operations;
|
return operations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Operation> getPendingOperations(DeviceIdentifier deviceIdentifier)
|
||||||
|
throws OperationManagementException {
|
||||||
|
List<Operation> operations = new ArrayList<Operation>();
|
||||||
|
List<MobileDeviceOperationMapping> mobileDeviceOperationMappings = null;
|
||||||
|
List<MobileOperationProperty> operationProperties = null;
|
||||||
|
MobileOperation mobileOperation = null;
|
||||||
|
try {
|
||||||
|
//Get the list of pending operations for the given device
|
||||||
|
mobileDeviceOperationMappings = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO()
|
||||||
|
.getAllPendingOperationsOfMobileDevice(
|
||||||
|
deviceIdentifier
|
||||||
|
.getId());
|
||||||
|
//Go through each operation mapping for retrieving the data corresponding to each operation
|
||||||
|
for (MobileDeviceOperationMapping operation : mobileDeviceOperationMappings) {
|
||||||
|
//Get the MobileOperation data
|
||||||
|
mobileOperation = MobileDeviceManagementDAOFactory.getMobileOperationDAO()
|
||||||
|
.getMobileOperation(operation
|
||||||
|
.getOperationId());
|
||||||
|
//Get properties of the operation
|
||||||
|
operationProperties =
|
||||||
|
MobileDeviceManagementDAOFactory.getMobileOperationPropertyDAO()
|
||||||
|
.getAllMobileOperationPropertiesOfOperation(
|
||||||
|
operation.getOperationId());
|
||||||
|
mobileOperation.setProperties(operationProperties);
|
||||||
|
operations.add(MobileDeviceManagementUtil
|
||||||
|
.convertMobileOperationToOperation(mobileOperation));
|
||||||
|
//Update the MobileDeviceOperationMapping data to the In-Progress state
|
||||||
|
operation.setStatus(MobileDeviceOperationMapping.Status.INPROGRESS);
|
||||||
|
operation.setSentDate(new Date().getTime());
|
||||||
|
MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO()
|
||||||
|
.updateMobileDeviceOperationToInProgress(
|
||||||
|
operation.getDeviceId(),
|
||||||
|
operation.getOperationId());
|
||||||
|
}
|
||||||
|
} catch (MobileDeviceManagementDAOException e) {
|
||||||
|
String msg =
|
||||||
|
"Error while fetching the operations for the android device " +
|
||||||
|
deviceIdentifier.getId();
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new OperationManagementException(msg, e);
|
||||||
|
}
|
||||||
|
return operations;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import org.wso2.carbon.device.mgt.common.Device;
|
|||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
import org.wso2.carbon.device.mgt.common.Operation;
|
import org.wso2.carbon.device.mgt.common.Operation;
|
||||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice;
|
import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice;
|
||||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperation;
|
import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperationMapping;
|
||||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation;
|
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation;
|
||||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperationProperty;
|
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperationProperty;
|
||||||
|
|
||||||
@ -60,39 +60,19 @@ public class MobileDeviceManagementUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getPropertyValue(Device device, String property) {
|
|
||||||
for (Device.Property prop : device.getProperties()) {
|
|
||||||
if (property.equals(prop.getName())) {
|
|
||||||
return prop.getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Device.Property getProperty(String property, String value) {
|
|
||||||
Device.Property prop = null;
|
|
||||||
if (property != null) {
|
|
||||||
prop = new Device.Property();
|
|
||||||
prop.setName(property);
|
|
||||||
prop.setValue(value);
|
|
||||||
return prop;
|
|
||||||
}
|
|
||||||
return prop;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MobileDevice convertToMobileDevice(Device device) {
|
public static MobileDevice convertToMobileDevice(Device device) {
|
||||||
MobileDevice mobileDevice = null;
|
MobileDevice mobileDevice = null;
|
||||||
if (device != null) {
|
if (device != null) {
|
||||||
mobileDevice = new MobileDevice();
|
mobileDevice = new MobileDevice();
|
||||||
mobileDevice.setMobileDeviceId(device.getDeviceIdentifier());
|
mobileDevice.setMobileDeviceId(device.getDeviceIdentifier());
|
||||||
mobileDevice.setImei(getPropertyValue(device, MOBILE_DEVICE_IMEI));
|
mobileDevice.setImei(device.getProperties().get(MOBILE_DEVICE_IMEI));
|
||||||
mobileDevice.setImsi(getPropertyValue(device, MOBILE_DEVICE_IMSI));
|
mobileDevice.setImsi(device.getProperties().get(MOBILE_DEVICE_IMSI));
|
||||||
mobileDevice.setRegId(getPropertyValue(device, MOBILE_DEVICE_REG_ID));
|
mobileDevice.setRegId(device.getProperties().get(MOBILE_DEVICE_REG_ID));
|
||||||
mobileDevice.setModel(getPropertyValue(device, MOBILE_DEVICE_MODEL));
|
mobileDevice.setModel(device.getProperties().get(MOBILE_DEVICE_MODEL));
|
||||||
mobileDevice.setOsVersion(getPropertyValue(device, MOBILE_DEVICE_OS_VERSION));
|
mobileDevice.setOsVersion(device.getProperties().get(MOBILE_DEVICE_OS_VERSION));
|
||||||
mobileDevice.setVendor(getPropertyValue(device, MOBILE_DEVICE_VENDOR));
|
mobileDevice.setVendor(device.getProperties().get(MOBILE_DEVICE_VENDOR));
|
||||||
mobileDevice.setLatitude(getPropertyValue(device, MOBILE_DEVICE_LATITUDE));
|
mobileDevice.setLatitude(device.getProperties().get(MOBILE_DEVICE_LATITUDE));
|
||||||
mobileDevice.setLongitude(getPropertyValue(device, MOBILE_DEVICE_LONGITUDE));
|
mobileDevice.setLongitude(device.getProperties().get(MOBILE_DEVICE_LONGITUDE));
|
||||||
}
|
}
|
||||||
return mobileDevice;
|
return mobileDevice;
|
||||||
}
|
}
|
||||||
@ -101,16 +81,16 @@ public class MobileDeviceManagementUtil {
|
|||||||
Device device = null;
|
Device device = null;
|
||||||
if (mobileDevice != null) {
|
if (mobileDevice != null) {
|
||||||
device = new Device();
|
device = new Device();
|
||||||
List<Device.Property> propertyList = new ArrayList<Device.Property>();
|
Map<String, String> propertyMap = new HashMap<String, String>();
|
||||||
propertyList.add(getProperty(MOBILE_DEVICE_IMEI, mobileDevice.getImei()));
|
propertyMap.put(MOBILE_DEVICE_IMEI, mobileDevice.getImei());
|
||||||
propertyList.add(getProperty(MOBILE_DEVICE_IMSI, mobileDevice.getImsi()));
|
propertyMap.put(MOBILE_DEVICE_IMSI, mobileDevice.getImsi());
|
||||||
propertyList.add(getProperty(MOBILE_DEVICE_REG_ID, mobileDevice.getRegId()));
|
propertyMap.put(MOBILE_DEVICE_REG_ID, mobileDevice.getRegId());
|
||||||
propertyList.add(getProperty(MOBILE_DEVICE_MODEL, mobileDevice.getModel()));
|
propertyMap.put(MOBILE_DEVICE_MODEL, mobileDevice.getModel());
|
||||||
propertyList.add(getProperty(MOBILE_DEVICE_OS_VERSION, mobileDevice.getOsVersion()));
|
propertyMap.put(MOBILE_DEVICE_OS_VERSION, mobileDevice.getOsVersion());
|
||||||
propertyList.add(getProperty(MOBILE_DEVICE_VENDOR, mobileDevice.getVendor()));
|
propertyMap.put(MOBILE_DEVICE_VENDOR, mobileDevice.getVendor());
|
||||||
propertyList.add(getProperty(MOBILE_DEVICE_LATITUDE, mobileDevice.getLatitude()));
|
propertyMap.put(MOBILE_DEVICE_LATITUDE, mobileDevice.getLatitude());
|
||||||
propertyList.add(getProperty(MOBILE_DEVICE_LONGITUDE, mobileDevice.getLongitude()));
|
propertyMap.put(MOBILE_DEVICE_LONGITUDE, mobileDevice.getLongitude());
|
||||||
device.setProperties(propertyList);
|
device.setProperties(propertyMap);
|
||||||
device.setDeviceIdentifier(mobileDevice.getMobileDeviceId());
|
device.setDeviceIdentifier(mobileDevice.getMobileDeviceId());
|
||||||
}
|
}
|
||||||
return device;
|
return device;
|
||||||
@ -135,10 +115,10 @@ public class MobileDeviceManagementUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<Integer> getMobileOperationIdsFromMobileDeviceOperations(
|
public static List<Integer> getMobileOperationIdsFromMobileDeviceOperations(
|
||||||
List<MobileDeviceOperation> mobileDeviceOperations) {
|
List<MobileDeviceOperationMapping> mobileDeviceOperationMappings) {
|
||||||
List<Integer> mobileOperationIds = new ArrayList<Integer>();
|
List<Integer> mobileOperationIds = new ArrayList<Integer>();
|
||||||
for(MobileDeviceOperation mobileDeviceOperation:mobileDeviceOperations){
|
for(MobileDeviceOperationMapping mobileDeviceOperationMapping : mobileDeviceOperationMappings){
|
||||||
mobileOperationIds.add(mobileDeviceOperation.getOperationId());
|
mobileOperationIds.add(mobileDeviceOperationMapping.getOperationId());
|
||||||
}
|
}
|
||||||
return mobileOperationIds;
|
return mobileOperationIds;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,119 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014 - 2015, 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.carbon.device.mgt.mobile.impl;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.testng.Assert;
|
||||||
|
import org.testng.annotations.BeforeClass;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceManagementConfig;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import javax.xml.XMLConstants;
|
||||||
|
import javax.xml.bind.JAXBContext;
|
||||||
|
import javax.xml.bind.JAXBException;
|
||||||
|
import javax.xml.bind.Unmarshaller;
|
||||||
|
import javax.xml.validation.Schema;
|
||||||
|
import javax.xml.validation.SchemaFactory;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class MobileDeviceManagementConfigTests {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(MobileDeviceManagementConfigTests.class);
|
||||||
|
private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_MGT_REPOSITORY =
|
||||||
|
"./src/test/resources/config/malformed-mobile-config-no-mgt-repo.xml";
|
||||||
|
private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_DS_CONFIG =
|
||||||
|
"./src/test/resources/config/malformed-mobile-config-no-ds-config.xml";
|
||||||
|
private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_JNDI_CONFIG =
|
||||||
|
"./src/test/resources/config/malformed-mobile-config-no-jndi-config.xml";
|
||||||
|
private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_APIS_CONFIG =
|
||||||
|
"./src/test/resources/config/malformed-mobile-config-no-apis-config.xml";
|
||||||
|
private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_API_CONFIG =
|
||||||
|
"./src/test/resources/config/malformed-mobile-config-no-api-config.xml";
|
||||||
|
private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_API_PUBLISHER_CONFIG =
|
||||||
|
"./src/test/resources/config/malformed-mobile-config-no-api-publisher-config.xml";
|
||||||
|
private static final String TEST_CONFIG_SCHEMA_LOCATION =
|
||||||
|
"./src/test/resources/config/schema/MobileDeviceManagementConfigSchema.xsd";
|
||||||
|
|
||||||
|
private Schema schema;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
private void initSchema() {
|
||||||
|
File deviceManagementSchemaConfig = new File(MobileDeviceManagementConfigTests.TEST_CONFIG_SCHEMA_LOCATION);
|
||||||
|
SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
|
||||||
|
try {
|
||||||
|
schema = factory.newSchema(deviceManagementSchemaConfig);
|
||||||
|
} catch (SAXException e) {
|
||||||
|
Assert.fail("Invalid schema found", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test()
|
||||||
|
public void testMandateManagementRepositoryElement() {
|
||||||
|
File malformedConfig =
|
||||||
|
new File(MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_MGT_REPOSITORY);
|
||||||
|
this.validateMalformedConfig(malformedConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMandateDataSourceConfigurationElement() {
|
||||||
|
File malformedConfig = new File(MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_DS_CONFIG);
|
||||||
|
this.validateMalformedConfig(malformedConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMandateJndiLookupDefinitionElement() {
|
||||||
|
File malformedConfig = new File(MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_JNDI_CONFIG);
|
||||||
|
this.validateMalformedConfig(malformedConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMandateAPIPublisherElement() {
|
||||||
|
File malformedConfig = new File(MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_API_PUBLISHER_CONFIG);
|
||||||
|
this.validateMalformedConfig(malformedConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMandateAPIsElement() {
|
||||||
|
File malformedConfig = new File(MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_APIS_CONFIG);
|
||||||
|
this.validateMalformedConfig(malformedConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMandateAPIElement() {
|
||||||
|
File malformedConfig = new File(MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_API_CONFIG);
|
||||||
|
this.validateMalformedConfig(malformedConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateMalformedConfig(File malformedConfig) {
|
||||||
|
try {
|
||||||
|
JAXBContext ctx = JAXBContext.newInstance(MobileDeviceManagementConfig.class);
|
||||||
|
Unmarshaller um = ctx.createUnmarshaller();
|
||||||
|
um.setSchema(this.getSchema());
|
||||||
|
um.unmarshal(malformedConfig);
|
||||||
|
Assert.assertTrue(false);
|
||||||
|
} catch (JAXBException e) {
|
||||||
|
log.error("Error occurred while unmarsharlling mobile device management config", e);
|
||||||
|
Assert.assertTrue(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Schema getSchema() {
|
||||||
|
return schema;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014 - 2015, 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.carbon.device.mgt.mobile.impl;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
|
||||||
|
public class TestUtils {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(TestUtils.class);
|
||||||
|
|
||||||
|
public static void cleanupResources(Connection conn, Statement stmt, ResultSet rs) {
|
||||||
|
if (rs != null) {
|
||||||
|
try {
|
||||||
|
rs.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.warn("Error occurred while closing result set", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (stmt != null) {
|
||||||
|
try {
|
||||||
|
stmt.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.warn("Error occurred while closing prepared statement", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (conn != null) {
|
||||||
|
try {
|
||||||
|
conn.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.warn("Error occurred while closing database connection", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,139 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.wso2.carbon.device.mgt.mobile.impl.dao;
|
||||||
|
|
||||||
|
import org.apache.commons.dbcp.BasicDataSource;
|
||||||
|
import org.testng.Assert;
|
||||||
|
import org.testng.annotations.BeforeClass;
|
||||||
|
import org.testng.annotations.Parameters;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.dao.impl.MobileFeatureDAOImpl;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.impl.common.DBTypes;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.impl.common.TestDBConfiguration;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.impl.common.TestDBConfigurations;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
|
||||||
|
|
||||||
|
import javax.xml.bind.JAXBContext;
|
||||||
|
import javax.xml.bind.JAXBException;
|
||||||
|
import javax.xml.bind.Unmarshaller;
|
||||||
|
import java.io.File;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.Statement;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
public class FeatureDAOTestSuite {
|
||||||
|
|
||||||
|
private TestDBConfiguration testDBConfiguration;
|
||||||
|
private Connection conn = null;
|
||||||
|
private Statement stmt = null;
|
||||||
|
private MobileFeatureDAOImpl featureDAO;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
@Parameters("dbType")
|
||||||
|
public void setUpDB(String dbTypeStr) throws Exception {
|
||||||
|
|
||||||
|
DBTypes dbType = DBTypes.valueOf(dbTypeStr);
|
||||||
|
testDBConfiguration = getTestDBConfiguration(dbType);
|
||||||
|
|
||||||
|
switch (dbType) {
|
||||||
|
case H2:
|
||||||
|
createH2DB(testDBConfiguration);
|
||||||
|
BasicDataSource testDataSource = new BasicDataSource();
|
||||||
|
testDataSource.setDriverClassName(testDBConfiguration.getDriverClass());
|
||||||
|
testDataSource.setUrl(testDBConfiguration.getConnectionUrl());
|
||||||
|
testDataSource.setUsername(testDBConfiguration.getUserName());
|
||||||
|
testDataSource.setPassword(testDBConfiguration.getPwd());
|
||||||
|
featureDAO = new MobileFeatureDAOImpl(testDataSource);
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private TestDBConfiguration getTestDBConfiguration(DBTypes dbType) throws
|
||||||
|
MobileDeviceManagementDAOException,
|
||||||
|
DeviceManagementException {
|
||||||
|
|
||||||
|
File deviceMgtConfig = new File("src/test/resources/testdbconfig.xml");
|
||||||
|
Document doc = null;
|
||||||
|
testDBConfiguration = null;
|
||||||
|
TestDBConfigurations testDBConfigurations = null;
|
||||||
|
|
||||||
|
doc = MobileDeviceManagementUtil.convertToDocument(deviceMgtConfig);
|
||||||
|
JAXBContext testDBContext = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
testDBContext = JAXBContext.newInstance(TestDBConfigurations.class);
|
||||||
|
Unmarshaller unmarshaller = testDBContext.createUnmarshaller();
|
||||||
|
testDBConfigurations = (TestDBConfigurations) unmarshaller.unmarshal(doc);
|
||||||
|
} catch (JAXBException e) {
|
||||||
|
throw new MobileDeviceManagementDAOException("Error parsing test db configurations", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator<TestDBConfiguration> itrDBConfigs =
|
||||||
|
testDBConfigurations.getDbTypesList().iterator();
|
||||||
|
while (itrDBConfigs.hasNext()) {
|
||||||
|
testDBConfiguration = itrDBConfigs.next();
|
||||||
|
if (testDBConfiguration.getDbType().equals(dbType.toString())) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return testDBConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createH2DB(TestDBConfiguration testDBConf) throws Exception {
|
||||||
|
Class.forName(testDBConf.getDriverClass());
|
||||||
|
conn = DriverManager.getConnection(testDBConf.getConnectionUrl());
|
||||||
|
stmt = conn.createStatement();
|
||||||
|
stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/sql/CreateH2TestDB.sql'");
|
||||||
|
stmt.close();
|
||||||
|
conn.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void addFeature() throws MobileDeviceManagementDAOException, DeviceManagementException {
|
||||||
|
|
||||||
|
MobileFeature mobileFeature = new MobileFeature();
|
||||||
|
mobileFeature.setCode("Camera");
|
||||||
|
mobileFeature.setDescription("Camera enable or disable");
|
||||||
|
mobileFeature.setName("Camera");
|
||||||
|
boolean added = featureDAO.addFeature(mobileFeature);
|
||||||
|
// Long deviceId = null;
|
||||||
|
// try {
|
||||||
|
// conn = DeviceManagementDAOFactory.getDataSource().getConnection();
|
||||||
|
// stmt = conn.createStatement();
|
||||||
|
// ResultSet resultSet = stmt
|
||||||
|
// .executeQuery("SELECT ID from DM_DEVICE DEVICE where DEVICE.DEVICE_IDENTIFICATION='111'");
|
||||||
|
//
|
||||||
|
// while (resultSet.next()) {
|
||||||
|
// deviceId = resultSet.getLong(1);
|
||||||
|
// }
|
||||||
|
// conn.close();
|
||||||
|
// } catch (SQLException sqlEx) {
|
||||||
|
// throw new DeviceManagementDAOException("error in fetch device by device identification id", sqlEx);
|
||||||
|
// }
|
||||||
|
|
||||||
|
Assert.assertTrue(added, "Device Id is null");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014 - 2015, 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.carbon.device.mgt.mobile.impl.dao;
|
||||||
|
|
||||||
|
public class FeaturePropertyDAOTestSuite {
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014 - 2015, 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.carbon.device.mgt.mobile.impl.dao;
|
||||||
|
|
||||||
|
public class MobileDeviceDAOTestSuite {
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014 - 2015, 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.carbon.device.mgt.mobile.impl.dao;
|
||||||
|
|
||||||
|
public class MobileDeviceOperationDAOTestSuite {
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014 - 2015, 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.carbon.device.mgt.mobile.impl.dao;
|
||||||
|
|
||||||
|
public class MobileOperationDAOTestSuite {
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014 - 2015, 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.carbon.device.mgt.mobile.impl.dao;
|
||||||
|
|
||||||
|
public class MobileOperationPropertyDAOTestSuite {
|
||||||
|
}
|
||||||
@ -1,141 +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 org.wso2.carbon.device.mgt.mobile.impl.dao;
|
|
||||||
|
|
||||||
import org.testng.Assert;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
|
||||||
import org.testng.annotations.Parameters;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.common.DBTypes;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.common.TestDBConfiguration;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.common.TestDBConfigurations;
|
|
||||||
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.dao.impl.FeatureDAOImpl;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.dto.*;
|
|
||||||
|
|
||||||
import javax.xml.bind.JAXBContext;
|
|
||||||
import javax.xml.bind.JAXBException;
|
|
||||||
import javax.xml.bind.Unmarshaller;
|
|
||||||
import java.io.File;
|
|
||||||
import java.sql.*;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
public class FeatureDAOTestSuite {
|
|
||||||
|
|
||||||
private TestDBConfiguration testDBConfiguration;
|
|
||||||
private Connection conn = null;
|
|
||||||
private Statement stmt = null;
|
|
||||||
private FeatureDAOImpl featureDAO;
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
@Parameters("dbType")
|
|
||||||
public void setUpDB(String dbTypeStr) throws Exception {
|
|
||||||
|
|
||||||
DBTypes dbType = DBTypes.valueOf(dbTypeStr);
|
|
||||||
testDBConfiguration = getTestDBConfiguration(dbType);
|
|
||||||
|
|
||||||
switch (dbType) {
|
|
||||||
case H2:
|
|
||||||
createH2DB(testDBConfiguration);
|
|
||||||
BasicDataSource testDataSource = new BasicDataSource();
|
|
||||||
testDataSource.setDriverClassName(testDBConfiguration.getDriverClass());
|
|
||||||
testDataSource.setUrl(testDBConfiguration.getConnectionUrl());
|
|
||||||
testDataSource.setUsername(testDBConfiguration.getUserName());
|
|
||||||
testDataSource.setPassword(testDBConfiguration.getPwd());
|
|
||||||
featureDAO = new FeatureDAOImpl(testDataSource);
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private TestDBConfiguration getTestDBConfiguration(DBTypes dbType) throws
|
|
||||||
MobileDeviceManagementDAOException,
|
|
||||||
DeviceManagementException {
|
|
||||||
|
|
||||||
File deviceMgtConfig = new File("src/test/resources/testdbconfig.xml");
|
|
||||||
Document doc = null;
|
|
||||||
testDBConfiguration = null;
|
|
||||||
TestDBConfigurations testDBConfigurations = null;
|
|
||||||
|
|
||||||
doc = DeviceManagerUtil.convertToDocument(deviceMgtConfig);
|
|
||||||
JAXBContext testDBContext = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
testDBContext = JAXBContext.newInstance(TestDBConfigurations.class);
|
|
||||||
Unmarshaller unmarshaller = testDBContext.createUnmarshaller();
|
|
||||||
testDBConfigurations = (TestDBConfigurations) unmarshaller.unmarshal(doc);
|
|
||||||
} catch (JAXBException e) {
|
|
||||||
throw new MobileDeviceManagementDAOException("Error parsing test db configurations", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
Iterator<TestDBConfiguration> itrDBConfigs = testDBConfigurations.getDbTypesList().iterator();
|
|
||||||
while (itrDBConfigs.hasNext()) {
|
|
||||||
testDBConfiguration = itrDBConfigs.next();
|
|
||||||
if (testDBConfiguration.getDbType().equals(dbType.toString())) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return testDBConfiguration;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createH2DB(TestDBConfiguration testDBConf) throws Exception {
|
|
||||||
|
|
||||||
Class.forName(testDBConf.getDriverClass());
|
|
||||||
conn = DriverManager.getConnection(testDBConf.getConnectionUrl());
|
|
||||||
stmt = conn.createStatement();
|
|
||||||
stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/sql/CreateH2TestDB.sql'");
|
|
||||||
stmt.close();
|
|
||||||
conn.close();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void addFeature() throws MobileDeviceManagementDAOException, DeviceManagementException {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Feature feature = new Feature();
|
|
||||||
feature.setCode("Camera");
|
|
||||||
feature.setDescription("Camera enable or disable");
|
|
||||||
feature.setName("Camera");
|
|
||||||
boolean added = featureDAO.addFeature(feature);
|
|
||||||
// Long deviceId = null;
|
|
||||||
// try {
|
|
||||||
// conn = DeviceManagementDAOFactory.getDataSource().getConnection();
|
|
||||||
// stmt = conn.createStatement();
|
|
||||||
// ResultSet resultSet = stmt
|
|
||||||
// .executeQuery("SELECT ID from DM_DEVICE DEVICE where DEVICE.DEVICE_IDENTIFICATION='111'");
|
|
||||||
//
|
|
||||||
// while (resultSet.next()) {
|
|
||||||
// deviceId = resultSet.getLong(1);
|
|
||||||
// }
|
|
||||||
// conn.close();
|
|
||||||
// } catch (SQLException sqlEx) {
|
|
||||||
// throw new DeviceManagementDAOException("error in fetch device by device identification id", sqlEx);
|
|
||||||
// }
|
|
||||||
|
|
||||||
Assert.assertTrue(added, "Device Id is null");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2014 - 2015, 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<MobileDeviceMgtConfiguration>
|
||||||
|
<ManagementRepository>
|
||||||
|
<DataSourceConfiguration>
|
||||||
|
<JndiLookupDefinition>
|
||||||
|
<Name>jdbc/MobileDM_DS</Name>
|
||||||
|
</JndiLookupDefinition>
|
||||||
|
</DataSourceConfiguration>
|
||||||
|
</ManagementRepository>
|
||||||
|
|
||||||
|
<APIPublisher>
|
||||||
|
<APIs>
|
||||||
|
<MalformedAPI>
|
||||||
|
<Name>enrollment</Name>
|
||||||
|
<Owner>admin</Owner>
|
||||||
|
<Context>enrollment</Context>
|
||||||
|
<Version>1.0.0</Version>
|
||||||
|
<Endpoint>http://localhost:9763/</Endpoint>
|
||||||
|
<Transports>http,https</Transports>
|
||||||
|
</MalformedAPI>
|
||||||
|
</APIs>
|
||||||
|
</APIPublisher>
|
||||||
|
</MobileDeviceMgtConfiguration>
|
||||||
|
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2014 - 2015, 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<MobileDeviceMgtConfiguration>
|
||||||
|
<ManagementRepository>
|
||||||
|
<DataSourceConfiguration>
|
||||||
|
<JndiLookupDefinition>
|
||||||
|
<Name>jdbc/MobileDM_DS</Name>
|
||||||
|
</JndiLookupDefinition>
|
||||||
|
</DataSourceConfiguration>
|
||||||
|
</ManagementRepository>
|
||||||
|
|
||||||
|
<MalformedAPIPublisher>
|
||||||
|
<APIs>
|
||||||
|
<API>
|
||||||
|
<Name>enrollment</Name>
|
||||||
|
<Owner>admin</Owner>
|
||||||
|
<Context>enrollment</Context>
|
||||||
|
<Version>1.0.0</Version>
|
||||||
|
<Endpoint>http://localhost:9763/</Endpoint>
|
||||||
|
<Transports>http,https</Transports>
|
||||||
|
</API>
|
||||||
|
</APIs>
|
||||||
|
</MalformedAPIPublisher>
|
||||||
|
</MobileDeviceMgtConfiguration>
|
||||||
|
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2014 - 2015, 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<MobileDeviceMgtConfiguration>
|
||||||
|
<ManagementRepository>
|
||||||
|
<DataSourceConfiguration>
|
||||||
|
<JndiLookupDefinition>
|
||||||
|
<Name>jdbc/MobileDM_DS</Name>
|
||||||
|
</JndiLookupDefinition>
|
||||||
|
</DataSourceConfiguration>
|
||||||
|
</ManagementRepository>
|
||||||
|
|
||||||
|
<APIPublisher>
|
||||||
|
<MalformedAPIs>
|
||||||
|
<API>
|
||||||
|
<Name>enrollment</Name>
|
||||||
|
<Owner>admin</Owner>
|
||||||
|
<Context>enrollment</Context>
|
||||||
|
<Version>1.0.0</Version>
|
||||||
|
<Endpoint>http://localhost:9763/</Endpoint>
|
||||||
|
<Transports>http,https</Transports>
|
||||||
|
</API>
|
||||||
|
</MalformedAPIs>
|
||||||
|
</APIPublisher>
|
||||||
|
</MobileDeviceMgtConfiguration>
|
||||||
|
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2014 - 2015, 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<MobileDeviceMgtConfiguration>
|
||||||
|
<ManagementRepository>
|
||||||
|
<MalformedDataSourceConfiguration>
|
||||||
|
<JndiLookupDefinition>
|
||||||
|
<Name>jdbc/MobileDM_DS</Name>
|
||||||
|
</JndiLookupDefinition>
|
||||||
|
</MalformedDataSourceConfiguration>
|
||||||
|
</ManagementRepository>
|
||||||
|
|
||||||
|
<APIPublisher>
|
||||||
|
<APIs>
|
||||||
|
<API>
|
||||||
|
<Name>enrollment</Name>
|
||||||
|
<Owner>admin</Owner>
|
||||||
|
<Context>enrollment</Context>
|
||||||
|
<Version>1.0.0</Version>
|
||||||
|
<Endpoint>http://localhost:9763/</Endpoint>
|
||||||
|
<Transports>http,https</Transports>
|
||||||
|
</API>
|
||||||
|
</APIs>
|
||||||
|
</APIPublisher>
|
||||||
|
</MobileDeviceMgtConfiguration>
|
||||||
|
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2014 - 2015, 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<MobileDeviceMgtConfiguration>
|
||||||
|
<ManagementRepository>
|
||||||
|
<DataSourceConfiguration>
|
||||||
|
<MalformedJndiLookupDefinition>
|
||||||
|
<Name>jdbc/MobileDM_DS</Name>
|
||||||
|
</MalformedJndiLookupDefinition>
|
||||||
|
</DataSourceConfiguration>
|
||||||
|
</ManagementRepository>
|
||||||
|
|
||||||
|
<APIPublisher>
|
||||||
|
<APIs>
|
||||||
|
<API>
|
||||||
|
<Name>enrollment</Name>
|
||||||
|
<Owner>admin</Owner>
|
||||||
|
<Context>enrollment</Context>
|
||||||
|
<Version>1.0.0</Version>
|
||||||
|
<Endpoint>http://localhost:9763/</Endpoint>
|
||||||
|
<Transports>http,https</Transports>
|
||||||
|
</API>
|
||||||
|
</APIs>
|
||||||
|
</APIPublisher>
|
||||||
|
</MobileDeviceMgtConfiguration>
|
||||||
|
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2014 - 2015, 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<MobileDeviceMgtConfiguration>
|
||||||
|
<MalformedManagementRepository>
|
||||||
|
<DataSourceConfiguration>
|
||||||
|
<JndiLookupDefinition>
|
||||||
|
<Name>jdbc/MobileDM_DS</Name>
|
||||||
|
</JndiLookupDefinition>
|
||||||
|
</DataSourceConfiguration>
|
||||||
|
</MalformedManagementRepository>
|
||||||
|
|
||||||
|
<APIPublisher>
|
||||||
|
<APIs>
|
||||||
|
<API>
|
||||||
|
<Name>enrollment</Name>
|
||||||
|
<Owner>admin</Owner>
|
||||||
|
<Context>enrollment</Context>
|
||||||
|
<Version>1.0.0</Version>
|
||||||
|
<Endpoint>http://localhost:9763/</Endpoint>
|
||||||
|
<Transports>http,https</Transports>
|
||||||
|
</API>
|
||||||
|
</APIs>
|
||||||
|
</APIPublisher>
|
||||||
|
</MobileDeviceMgtConfiguration>
|
||||||
|
|
||||||
@ -0,0 +1,67 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2014 - 2015, 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.
|
||||||
|
-->
|
||||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
|
||||||
|
attributeFormDefault="unqualified">
|
||||||
|
<xs:element name="MobileDeviceMgtConfiguration">
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element name="ManagementRepository" minOccurs="1" maxOccurs="1"
|
||||||
|
type="DataSourceConfigurationType"/>
|
||||||
|
<xs:element name="APIPublisher" minOccurs="1" maxOccurs="1"
|
||||||
|
type="APIsConfigurationType"/>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
|
||||||
|
<xs:complexType name="JndiLookupDefinitionType">
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element name="Name" type="xs:string" minOccurs="1" maxOccurs="1"/>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
|
||||||
|
<xs:complexType name="DataSourceConfigurationType">
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element name="JndiLookupDefinition" minOccurs="1" maxOccurs="1"
|
||||||
|
type="JndiLookupDefinitionType"/>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
|
||||||
|
<xs:complexType name="ManagementRepositoryType">
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element name="DataSourceConfiguration" minOccurs="1" maxOccurs="1"
|
||||||
|
type="DataSourceConfigurationType"/>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
|
||||||
|
<xs:complexType name="APIConfigurationType">
|
||||||
|
<xs:all>
|
||||||
|
<xs:element name="Name" type="xs:string" minOccurs="1" maxOccurs="1"/>
|
||||||
|
<xs:element name="Owner" type="xs:string" minOccurs="1" maxOccurs="1"/>
|
||||||
|
<xs:element name="Context" type="xs:string" minOccurs="1" maxOccurs="1"/>
|
||||||
|
<xs:element name="Version" type="xs:string" minOccurs="1" maxOccurs="1"/>
|
||||||
|
<xs:element name="Endpoint" type="xs:string" minOccurs="1" maxOccurs="1"/>
|
||||||
|
<xs:element name="Transports" type="xs:string" minOccurs="1" maxOccurs="1"/>
|
||||||
|
</xs:all>
|
||||||
|
</xs:complexType>
|
||||||
|
|
||||||
|
<xs:complexType name="APIsConfigurationType">
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element name="API" maxOccurs="unbounded"
|
||||||
|
type="APIConfigurationType"/>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:schema>
|
||||||
@ -1,24 +1,82 @@
|
|||||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE
|
|
||||||
(
|
|
||||||
ID INT auto_increment NOT NULL,
|
|
||||||
NAME VARCHAR(300) NULL DEFAULT NULL,
|
|
||||||
PRIMARY KEY (ID)
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS DM_DEVICE
|
-- -----------------------------------------------------
|
||||||
(
|
-- Table `MBL_DEVICE`
|
||||||
ID INT auto_increment NOT NULL,
|
-- -----------------------------------------------------
|
||||||
DESCRIPTION TEXT NULL DEFAULT NULL,
|
CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
|
||||||
NAME VARCHAR(100) NULL DEFAULT NULL,
|
`MOBILE_DEVICE_ID` VARCHAR(45) NOT NULL ,
|
||||||
DATE_OF_ENROLLMENT BIGINT NULL DEFAULT NULL,
|
`REG_ID` VARCHAR(45) NULL DEFAULT NULL ,
|
||||||
DATE_OF_LAST_UPDATE BIGINT NULL DEFAULT NULL,
|
`IMEI` VARCHAR(45) NULL DEFAULT NULL ,
|
||||||
OWNERSHIP VARCHAR(45) NULL DEFAULT NULL,
|
`IMSI` VARCHAR(45) NULL DEFAULT NULL ,
|
||||||
STATUS VARCHAR(15) NULL DEFAULT NULL,
|
`OS_VERSION` VARCHAR(45) NULL DEFAULT NULL ,
|
||||||
DEVICE_TYPE_ID INT(11) NULL DEFAULT NULL,
|
`DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL ,
|
||||||
DEVICE_IDENTIFICATION VARCHAR(300) NULL DEFAULT NULL,
|
`VENDOR` VARCHAR(45) NULL DEFAULT NULL ,
|
||||||
OWNER VARCHAR(45) NULL DEFAULT NULL,
|
`LATITUDE` VARCHAR(45) NULL DEFAULT NULL,
|
||||||
TENANT_ID INTEGER DEFAULT 0,
|
`LONGITUDE` VARCHAR(45) NULL DEFAULT NULL,
|
||||||
PRIMARY KEY (ID),
|
PRIMARY KEY (`MOBILE_DEVICE_ID`) );
|
||||||
CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID )
|
|
||||||
REFERENCES DM_DEVICE_TYPE (ID ) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
||||||
);
|
-- -----------------------------------------------------
|
||||||
|
-- Table `MBL_FEATURE`
|
||||||
|
-- -----------------------------------------------------
|
||||||
|
CREATE TABLE IF NOT EXISTS `MBL_FEATURE` (
|
||||||
|
`FEATURE_ID` INT NOT NULL AUTO_INCREMENT ,
|
||||||
|
`CODE` VARCHAR(45) NOT NULL ,
|
||||||
|
`NAME` VARCHAR(100) NULL ,
|
||||||
|
`DESCRIPTION` VARCHAR(200) NULL ,
|
||||||
|
PRIMARY KEY (`FEATURE_ID`) );
|
||||||
|
|
||||||
|
-- -----------------------------------------------------
|
||||||
|
-- Table `MBL_OPERATION`
|
||||||
|
-- -----------------------------------------------------
|
||||||
|
CREATE TABLE IF NOT EXISTS `MBL_OPERATION` (
|
||||||
|
`OPERATION_ID` INT NOT NULL AUTO_INCREMENT ,
|
||||||
|
`FEATURE_CODE` VARCHAR(45) NOT NULL ,
|
||||||
|
`CREATED_DATE` BIGINT NULL ,
|
||||||
|
PRIMARY KEY (`OPERATION_ID`));
|
||||||
|
|
||||||
|
-- -----------------------------------------------------
|
||||||
|
-- Table `MBL_DEVICE_OPERATION_MAPPING`
|
||||||
|
-- -----------------------------------------------------
|
||||||
|
CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPPING` (
|
||||||
|
`DEVICE_ID` VARCHAR(45) NOT NULL ,
|
||||||
|
`OPERATION_ID` INT NOT NULL ,
|
||||||
|
`SENT_DATE` BIGINT NULL ,
|
||||||
|
`RECEIVED_DATE` BIGINT NULL ,
|
||||||
|
PRIMARY KEY (`DEVICE_ID`, `OPERATION_ID`) ,
|
||||||
|
CONSTRAINT `fk_MBL_DEVICE_OPERATION_MBL_DEVICE`
|
||||||
|
FOREIGN KEY (`DEVICE_ID` )
|
||||||
|
REFERENCES `MBL_DEVICE` (`MOBILE_DEVICE_ID` )
|
||||||
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT `fk_MBL_DEVICE_OPERATION_MBL_OPERATION1`
|
||||||
|
FOREIGN KEY (`OPERATION_ID` )
|
||||||
|
REFERENCES `MBL_OPERATION` (`OPERATION_ID` )
|
||||||
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION);
|
||||||
|
|
||||||
|
-- -----------------------------------------------------
|
||||||
|
-- Table `MBL_OPERATION_PROPERTY`
|
||||||
|
-- -----------------------------------------------------
|
||||||
|
CREATE TABLE IF NOT EXISTS `MBL_OPERATION_PROPERTY` (
|
||||||
|
`OPERATION_ID` INT NOT NULL ,
|
||||||
|
`PROPERTY` VARCHAR(45) NOT NULL ,
|
||||||
|
`VALUE` TEXT NULL ,
|
||||||
|
PRIMARY KEY (`OPERATION_ID`, `PROPERTY`) ,
|
||||||
|
CONSTRAINT `fk_MBL_OPERATION_PROPERTY_MBL_OPERATION1`
|
||||||
|
FOREIGN KEY (`OPERATION_ID` )
|
||||||
|
REFERENCES `MBL_OPERATION` (`OPERATION_ID` )
|
||||||
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION);
|
||||||
|
|
||||||
|
-- -----------------------------------------------------
|
||||||
|
-- Table `MBL_FEATURE_PROPERTY`
|
||||||
|
-- -----------------------------------------------------
|
||||||
|
CREATE TABLE IF NOT EXISTS `MBL_FEATURE_PROPERTY` (
|
||||||
|
`PROPERTY` VARCHAR(45) NOT NULL ,
|
||||||
|
`FEATURE_ID` VARCHAR(45) NOT NULL ,
|
||||||
|
PRIMARY KEY (`PROPERTY`) ,
|
||||||
|
CONSTRAINT `fk_MBL_FEATURE_PROPERTY_MBL_FEATURE1`
|
||||||
|
FOREIGN KEY (`FEATURE_ID` )
|
||||||
|
REFERENCES `MBL_FEATURE` (`FEATURE_ID` )
|
||||||
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION);
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
<DeviceMgtTestDBConfigurations>
|
<DeviceMgtTestDBConfigurations>
|
||||||
<DBType typeName="H2">
|
<DBType typeName="H2">
|
||||||
<connectionurl>jdbc:h2:mem:cdm-test-db;DB_CLOSE_DELAY=-1</connectionurl>
|
<connectionurl>jdbc:h2:mem:cdm-mobile-test-db;DB_CLOSE_DELAY=-1</connectionurl>
|
||||||
<driverclass>org.h2.Driver</driverclass>
|
<driverclass>org.h2.Driver</driverclass>
|
||||||
<userName></userName>
|
<userName></userName>
|
||||||
<pwd></pwd>
|
<pwd></pwd>
|
||||||
|
|||||||
@ -15,13 +15,12 @@
|
|||||||
|
|
||||||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
|
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
|
||||||
|
|
||||||
<suite name="EMM-core-initializer">
|
<suite name="CDM-Mobile-Tests">
|
||||||
<parameter name="useDefaultListeners" value="false"/>
|
<parameter name="useDefaultListeners" value="false"/>
|
||||||
|
|
||||||
<test name="DAO Unit Tests" preserve-order="true">
|
<test name="DAO Unit Tests" preserve-order="true">
|
||||||
<parameter name="dbType" value="H2"/>
|
<parameter name="dbType" value="H2"/>
|
||||||
<classes>
|
<classes>
|
||||||
|
|
||||||
<class name="org.wso2.carbon.device.mgt.mobile.impl.dao.FeatureDAOTestSuite"/>
|
<class name="org.wso2.carbon.device.mgt.mobile.impl.dao.FeatureDAOTestSuite"/>
|
||||||
</classes>
|
</classes>
|
||||||
</test>
|
</test>
|
||||||
|
|||||||
@ -33,7 +33,7 @@
|
|||||||
<artifactId>device-mgt</artifactId>
|
<artifactId>device-mgt</artifactId>
|
||||||
<version>2.0.0-SNAPSHOT</version>
|
<version>2.0.0-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>WSO2 Carbon - Device Management Component</name>
|
<name>WSO2 Carbon - Mobile Device Management Component</name>
|
||||||
<url>http://wso2.org</url>
|
<url>http://wso2.org</url>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
|
|||||||
@ -33,64 +33,13 @@
|
|||||||
<artifactId>key-mgt</artifactId>
|
<artifactId>key-mgt</artifactId>
|
||||||
<version>2.0.0-SNAPSHOT</version>
|
<version>2.0.0-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>WSO2 Carbon - Device Management Component</name>
|
<name>WSO2 Carbon - Oauth Key Management Component</name>
|
||||||
<url>http://wso2.org</url>
|
<url>http://wso2.org</url>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>org.wso2.carbon.key.mgt.handler.valve</module>
|
<module>org.wso2.carbon.key.mgt.handler.valve</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<!--
|
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.eclipse.osgi</groupId>
|
|
||||||
<artifactId>org.eclipse.osgi</artifactId>
|
|
||||||
<version>3.8.1.v20120830-144521</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.eclipse.equinox</groupId>
|
|
||||||
<artifactId>org.eclipse.equinox.common</artifactId>
|
|
||||||
<version>3.6.100.v20120522-1841</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.wso2.carbon</groupId>
|
|
||||||
<artifactId>org.wso2.carbon.logging</artifactId>
|
|
||||||
<version>4.3.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.wso2.carbon</groupId>
|
|
||||||
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
|
||||||
<version>2.0.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.eclipse.osgi</groupId>
|
|
||||||
<artifactId>org.eclipse.osgi.services</artifactId>
|
|
||||||
<version>3.3.100.v20120522-1822</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.wso2.carbon</groupId>
|
|
||||||
<artifactId>org.wso2.carbon.apimgt.core</artifactId>
|
|
||||||
<version>${apim.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.wso2.carbon</groupId>
|
|
||||||
<artifactId>org.wso2.carbon.apimgt.impl</artifactId>
|
|
||||||
<version>${apim.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.tomcat.wso2</groupId>
|
|
||||||
<artifactId>tomcat</artifactId>
|
|
||||||
<version>${orbit.version.tomcat}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.wso2.carbon</groupId>
|
|
||||||
<artifactId>org.wso2.carbon.tomcat.ext</artifactId>
|
|
||||||
<version>4.3.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<pluginManagement>
|
<pluginManagement>
|
||||||
@ -111,9 +60,5 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
</build>
|
</build>
|
||||||
<!-- <properties>
|
|
||||||
<orbit.version.h2.engine>1.2.140.wso2v3</orbit.version.h2.engine>
|
|
||||||
<apim.version>1.2.1</apim.version>
|
|
||||||
<orbit.version.tomcat>7.0.52.wso2v5</orbit.version.tomcat>
|
|
||||||
</properties>-->
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@ -39,12 +39,10 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.wso2.carbon</groupId>
|
<groupId>org.wso2.carbon</groupId>
|
||||||
<artifactId>org.wso2.carbon.device.mgt.mobile.impl</artifactId>
|
<artifactId>org.wso2.carbon.device.mgt.mobile.impl</artifactId>
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.wso2.carbon</groupId>
|
<groupId>org.wso2.carbon</groupId>
|
||||||
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
@ -102,7 +100,7 @@
|
|||||||
<importFeatures>
|
<importFeatures>
|
||||||
<importFeatureDef>org.wso2.carbon.core.server:${carbon.kernel.version}
|
<importFeatureDef>org.wso2.carbon.core.server:${carbon.kernel.version}
|
||||||
</importFeatureDef>
|
</importFeatureDef>
|
||||||
<importFeatureDef>org.wso2.carbon.device.mgt.server:${project.version}
|
<importFeatureDef>org.wso2.carbon.device.mgt.server:${cdm.core.version}
|
||||||
</importFeatureDef>
|
</importFeatureDef>
|
||||||
</importFeatures>
|
</importFeatures>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
25
pom.xml
25
pom.xml
@ -100,23 +100,29 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.wso2.carbon</groupId>
|
<groupId>org.wso2.carbon</groupId>
|
||||||
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
|
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${cdm.core.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.wso2.carbon</groupId>
|
<groupId>org.wso2.carbon</groupId>
|
||||||
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||||
|
<version>${cdm.core.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.device.mgt.mobile.impl</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.wso2.carbon</groupId>
|
<groupId>org.wso2.carbon</groupId>
|
||||||
<artifactId>org.wso2.carbon.policy.mgt.common</artifactId>
|
<artifactId>org.wso2.carbon.policy.mgt.common</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${cdm.core.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.wso2.carbon</groupId>
|
<groupId>org.wso2.carbon</groupId>
|
||||||
<artifactId>org.wso2.carbon.policy.mgt.core</artifactId>
|
<artifactId>org.wso2.carbon.policy.mgt.core</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${cdm.core.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
@ -197,8 +203,18 @@
|
|||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<testng.version>6.1.1</testng.version>
|
|
||||||
|
<!--Carbon kernel versions-->
|
||||||
<carbon.kernel.version>4.3.0</carbon.kernel.version>
|
<carbon.kernel.version>4.3.0</carbon.kernel.version>
|
||||||
|
<carbon.kernel.version.range>[4.3.0, 4.4.0)</carbon.kernel.version.range>
|
||||||
|
|
||||||
|
<!--CDM versions-->
|
||||||
|
<cdm.core.version>1.0.0-SNAPSHOT</cdm.core.version>
|
||||||
|
<cdm.core.version.range>[1.0.0, 2.0.0)</cdm.core.version.range>
|
||||||
|
|
||||||
|
|
||||||
|
<testng.version>6.1.1</testng.version>
|
||||||
|
|
||||||
<carbon.platform.version>4.3.0-SNAPSHOT</carbon.platform.version>
|
<carbon.platform.version>4.3.0-SNAPSHOT</carbon.platform.version>
|
||||||
<carbon.p2.plugin.version>1.5.4</carbon.p2.plugin.version>
|
<carbon.p2.plugin.version>1.5.4</carbon.p2.plugin.version>
|
||||||
<maven-buildnumber-plugin.version>1.3</maven-buildnumber-plugin.version>
|
<maven-buildnumber-plugin.version>1.3</maven-buildnumber-plugin.version>
|
||||||
@ -211,6 +227,7 @@
|
|||||||
<carbon.feature.version>1.1.0</carbon.feature.version>
|
<carbon.feature.version>1.1.0</carbon.feature.version>
|
||||||
<process.feature.version>1.0.0</process.feature.version>
|
<process.feature.version>1.0.0</process.feature.version>
|
||||||
<uuid.feature.version>1.0.0</uuid.feature.version>
|
<uuid.feature.version>1.0.0</uuid.feature.version>
|
||||||
|
<sso.feature.version>1.1.0-SNAPSHOT</sso.feature.version>
|
||||||
<jaggery-test.feature.version>1.1.0</jaggery-test.feature.version>
|
<jaggery-test.feature.version>1.1.0</jaggery-test.feature.version>
|
||||||
<!--Testing -->
|
<!--Testing -->
|
||||||
<test.framework.version>4.3.1</test.framework.version>
|
<test.framework.version>4.3.1</test.framework.version>
|
||||||
|
|||||||
@ -22,17 +22,17 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.wso2.cdmserver</groupId>
|
<groupId>org.wso2.mdmserver</groupId>
|
||||||
<artifactId>wso2cdmserver-product</artifactId>
|
<artifactId>wso2mdmserver-product</artifactId>
|
||||||
<version>2.0.0-SNAPSHOT</version>
|
<version>2.0.0-SNAPSHOT</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>wso2cdm</artifactId>
|
<artifactId>wso2mdm</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>WSO2 Connected Device Manager (CDM) - Distribution</name>
|
<name>WSO2 Mobile Device Manager (MDM) - Distribution</name>
|
||||||
<description>WSO2 Connected Device Manager (CDM) Distribution</description>
|
<description>WSO2 Mobile Device Manager (MDM) Distribution</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -213,18 +213,18 @@
|
|||||||
<!--<property name="shindig.version" value="2.5.0-beta5"/>-->
|
<!--<property name="shindig.version" value="2.5.0-beta5"/>-->
|
||||||
|
|
||||||
<mkdir dir="${tempdir}"/>
|
<mkdir dir="${tempdir}"/>
|
||||||
<mkdir dir="${tempdir}/wso2cdm-${project.version}/repository/components"/>
|
<mkdir dir="${tempdir}/wso2mdm-${project.version}/repository/components"/>
|
||||||
<mkdir dir="${tempdir}/wso2cdm-${project.version}/repository/deployment/server"/>
|
<mkdir dir="${tempdir}/wso2mdm-${project.version}/repository/deployment/server"/>
|
||||||
<mkdir dir="${tempdir}/wso2cdm-${project.version}/repository/deployment/server/webapps"/>
|
<mkdir dir="${tempdir}/wso2mdm-${project.version}/repository/deployment/server/webapps"/>
|
||||||
<unzip dest="${tempdir}">
|
<unzip dest="${tempdir}">
|
||||||
<fileset dir="target">
|
<fileset dir="target">
|
||||||
<include name="wso2cdm-${project.version}.zip"/>
|
<include name="wso2mdm-${project.version}.zip"/>
|
||||||
</fileset>
|
</fileset>
|
||||||
</unzip>
|
</unzip>
|
||||||
<copy todir="target/wso2carbon-core-${carbon.kernel.version}/repository/components"
|
<copy todir="target/wso2carbon-core-${carbon.kernel.version}/repository/components"
|
||||||
overwrite="true">
|
overwrite="true">
|
||||||
<fileset
|
<fileset
|
||||||
dir="${tempdir}/wso2cdm-${project.version}/repository/components"></fileset>
|
dir="${tempdir}/wso2mdm-${project.version}/repository/components"></fileset>
|
||||||
</copy>
|
</copy>
|
||||||
<!--testing -->
|
<!--testing -->
|
||||||
<!--<unzip src="target/shindig/WEB-INF/lib/shindig-common-${shindig.version}.jar"
|
<!--<unzip src="target/shindig/WEB-INF/lib/shindig-common-${shindig.version}.jar"
|
||||||
@ -248,7 +248,7 @@
|
|||||||
og4j.logger.net.sf.ehcache=ERROR
|
og4j.logger.net.sf.ehcache=ERROR
|
||||||
</concat>
|
</concat>
|
||||||
|
|
||||||
<delete file="target/wso2cdm-${project.version}.zip"/>
|
<delete file="target/wso2mdm-${project.version}.zip"/>
|
||||||
<delete dir="${tempdir}"/>
|
<delete dir="${tempdir}"/>
|
||||||
</tasks>
|
</tasks>
|
||||||
</configuration>
|
</configuration>
|
||||||
@ -292,7 +292,7 @@
|
|||||||
<delete dir="target/maven-archiver"/>
|
<delete dir="target/maven-archiver"/>
|
||||||
<delete dir="target/wso2carbon-core-${carbon.kernel.version}"/>
|
<delete dir="target/wso2carbon-core-${carbon.kernel.version}"/>
|
||||||
<delete dir="target/wso2carbon-core-${carbon.kernel.version}"/>
|
<delete dir="target/wso2carbon-core-${carbon.kernel.version}"/>
|
||||||
<delete file="target/wso2cdm-${project.version}.jar"/>
|
<delete file="target/wso2mdm-${project.version}.jar"/>
|
||||||
<delete dir="target/sources"/>
|
<delete dir="target/sources"/>
|
||||||
<delete dir="target/site"/>
|
<delete dir="target/site"/>
|
||||||
<delete dir="target/antrun"/>
|
<delete dir="target/antrun"/>
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
<fileSets>
|
<fileSets>
|
||||||
<fileSet>
|
<fileSet>
|
||||||
<directory>target/wso2carbon-core-${carbon.kernel.version}</directory>
|
<directory>target/wso2carbon-core-${carbon.kernel.version}</directory>
|
||||||
<outputDirectory>wso2cdm-${pom.version}</outputDirectory>
|
<outputDirectory>wso2mdm-${pom.version}</outputDirectory>
|
||||||
<!-- <excludes>
|
<!-- <excludes>
|
||||||
<exclude>**/*.sh</exclude>
|
<exclude>**/*.sh</exclude>
|
||||||
<exclude>**/README*</exclude>
|
<exclude>**/README*</exclude>
|
||||||
@ -29,14 +29,14 @@
|
|||||||
<directory>
|
<directory>
|
||||||
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/lib/runtimes
|
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/lib/runtimes
|
||||||
</directory>
|
</directory>
|
||||||
<outputDirectory>wso2cdm-${pom.version}/lib/runtimes/</outputDirectory>
|
<outputDirectory>wso2mdm-${pom.version}/lib/runtimes/</outputDirectory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>*/**</include>
|
<include>*/**</include>
|
||||||
</includes>
|
</includes>
|
||||||
</fileSet>
|
</fileSet>
|
||||||
<fileSet>
|
<fileSet>
|
||||||
<directory>target/wso2carbon-core-${carbon.kernel.version}</directory>
|
<directory>target/wso2carbon-core-${carbon.kernel.version}</directory>
|
||||||
<outputDirectory>wso2cdm-${pom.version}</outputDirectory>
|
<outputDirectory>wso2mdm-${pom.version}</outputDirectory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/*.sh</include>
|
<include>**/*.sh</include>
|
||||||
</includes>
|
</includes>
|
||||||
@ -48,7 +48,7 @@
|
|||||||
<directory>
|
<directory>
|
||||||
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/multitenancy/
|
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/multitenancy/
|
||||||
</directory>
|
</directory>
|
||||||
<outputDirectory>wso2cdm-${project.version}/repository/conf/multitenancy
|
<outputDirectory>wso2mdm-${project.version}/repository/conf/multitenancy
|
||||||
</outputDirectory>
|
</outputDirectory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/stratos.xml</include>
|
<include>**/stratos.xml</include>
|
||||||
@ -62,7 +62,7 @@
|
|||||||
<directory>
|
<directory>
|
||||||
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/multitenancy/
|
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/multitenancy/
|
||||||
</directory>
|
</directory>
|
||||||
<outputDirectory>wso2cdm-${project.version}/repository/conf</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}/repository/conf</outputDirectory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/tenant-mgt.xml</include>
|
<include>**/tenant-mgt.xml</include>
|
||||||
</includes>
|
</includes>
|
||||||
@ -70,7 +70,7 @@
|
|||||||
|
|
||||||
<fileSet>
|
<fileSet>
|
||||||
<directory>src/repository/resources/styles/css</directory>
|
<directory>src/repository/resources/styles/css</directory>
|
||||||
<outputDirectory>wso2cdm-${project.version}/resources/allthemes/Default/admin
|
<outputDirectory>wso2mdm-${project.version}/resources/allthemes/Default/admin
|
||||||
</outputDirectory>
|
</outputDirectory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/**.css</include>
|
<include>**/**.css</include>
|
||||||
@ -78,7 +78,7 @@
|
|||||||
</fileSet>
|
</fileSet>
|
||||||
<fileSet>
|
<fileSet>
|
||||||
<directory>src/repository/resources/styles/images</directory>
|
<directory>src/repository/resources/styles/images</directory>
|
||||||
<outputDirectory>wso2cdm-${project.version}/resources/allthemes/Default/images
|
<outputDirectory>wso2mdm-${project.version}/resources/allthemes/Default/images
|
||||||
</outputDirectory>
|
</outputDirectory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/**.gif</include>
|
<include>**/**.gif</include>
|
||||||
@ -89,7 +89,7 @@
|
|||||||
<!-- copy documentation -->
|
<!-- copy documentation -->
|
||||||
<fileSet>
|
<fileSet>
|
||||||
<directory>target/site</directory>
|
<directory>target/site</directory>
|
||||||
<outputDirectory>wso2cdm-${project.version}/docs</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}/docs</outputDirectory>
|
||||||
<fileMode>755</fileMode>
|
<fileMode>755</fileMode>
|
||||||
</fileSet>
|
</fileSet>
|
||||||
<!-- copy the landing page webapp -->
|
<!-- copy the landing page webapp -->
|
||||||
@ -109,7 +109,7 @@
|
|||||||
|
|
||||||
<fileSet>
|
<fileSet>
|
||||||
<directory>src/repository/conf</directory>
|
<directory>src/repository/conf</directory>
|
||||||
<outputDirectory>wso2cdm-${project.version}/repository/conf</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}/repository/conf</outputDirectory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/api-manager.xml</include>
|
<include>**/api-manager.xml</include>
|
||||||
<include>**/sso-idp-config.xml</include>
|
<include>**/sso-idp-config.xml</include>
|
||||||
@ -120,7 +120,7 @@
|
|||||||
<directory>
|
<directory>
|
||||||
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/security/
|
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/security/
|
||||||
</directory>
|
</directory>
|
||||||
<outputDirectory>wso2cdm-${project.version}/repository/conf/security/</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}/repository/conf/security/</outputDirectory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/entitlement.properties</include>
|
<include>**/entitlement.properties</include>
|
||||||
<include>**/trusted-idp-config.xml</include>
|
<include>**/trusted-idp-config.xml</include>
|
||||||
@ -131,12 +131,12 @@
|
|||||||
<directory>
|
<directory>
|
||||||
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources/rxts/
|
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources/rxts/
|
||||||
</directory>
|
</directory>
|
||||||
<outputDirectory>wso2cdm-${project.version}/repository/resources/rxts/</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}/repository/resources/rxts/</outputDirectory>
|
||||||
</fileSet>
|
</fileSet>
|
||||||
|
|
||||||
<fileSet>
|
<fileSet>
|
||||||
<directory>src/repository/conf/datasources</directory>
|
<directory>src/repository/conf/datasources</directory>
|
||||||
<outputDirectory>wso2cdm-${project.version}/repository/conf/datasources
|
<outputDirectory>wso2mdm-${project.version}/repository/conf/datasources
|
||||||
</outputDirectory>
|
</outputDirectory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/master-datasources.xml</include>
|
<include>**/master-datasources.xml</include>
|
||||||
@ -145,7 +145,7 @@
|
|||||||
</fileSet>
|
</fileSet>
|
||||||
<fileSet>
|
<fileSet>
|
||||||
<directory>src/repository/resources</directory>
|
<directory>src/repository/resources</directory>
|
||||||
<outputDirectory>wso2cdm-${project.version}/repository/resources</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}/repository/resources</outputDirectory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>*/**</include>
|
<include>*/**</include>
|
||||||
</includes>
|
</includes>
|
||||||
@ -153,7 +153,7 @@
|
|||||||
<!--data-bridge configuration-->
|
<!--data-bridge configuration-->
|
||||||
<fileSet>
|
<fileSet>
|
||||||
<directory>src/repository/conf/data-bridge</directory>
|
<directory>src/repository/conf/data-bridge</directory>
|
||||||
<outputDirectory>wso2cdm-${project.version}/repository/conf/data-bridge
|
<outputDirectory>wso2mdm-${project.version}/repository/conf/data-bridge
|
||||||
</outputDirectory>
|
</outputDirectory>
|
||||||
<fileMode>755</fileMode>
|
<fileMode>755</fileMode>
|
||||||
</fileSet>
|
</fileSet>
|
||||||
@ -161,7 +161,7 @@
|
|||||||
<directory>
|
<directory>
|
||||||
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/lib/runtimes
|
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/lib/runtimes
|
||||||
</directory>
|
</directory>
|
||||||
<outputDirectory>wso2cdm-${project.version}/lib/runtimes/</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}/lib/runtimes/</outputDirectory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>*/**</include>
|
<include>*/**</include>
|
||||||
</includes>
|
</includes>
|
||||||
@ -170,7 +170,7 @@
|
|||||||
<directory>
|
<directory>
|
||||||
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/dbscripts/service-provider
|
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/dbscripts/service-provider
|
||||||
</directory>
|
</directory>
|
||||||
<outputDirectory>wso2cdm-${project.version}/dbscripts/service-provider</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}/dbscripts/service-provider</outputDirectory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>*/**</include>
|
<include>*/**</include>
|
||||||
</includes>
|
</includes>
|
||||||
@ -181,7 +181,7 @@
|
|||||||
<directory>
|
<directory>
|
||||||
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/dbscripts/identity
|
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/dbscripts/identity
|
||||||
</directory>
|
</directory>
|
||||||
<outputDirectory>wso2cdm-${project.version}/dbscripts/identity</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}/dbscripts/identity</outputDirectory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>*/**</include>
|
<include>*/**</include>
|
||||||
</includes>
|
</includes>
|
||||||
@ -192,7 +192,7 @@
|
|||||||
<directory>
|
<directory>
|
||||||
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/dbscripts/apimgt
|
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/dbscripts/apimgt
|
||||||
</directory>
|
</directory>
|
||||||
<outputDirectory>wso2cdm-${project.version}/dbscripts/apimgt</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}/dbscripts/apimgt</outputDirectory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>*/**</include>
|
<include>*/**</include>
|
||||||
</includes>
|
</includes>
|
||||||
@ -202,7 +202,7 @@
|
|||||||
<directory>
|
<directory>
|
||||||
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/modules
|
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/modules
|
||||||
</directory>
|
</directory>
|
||||||
<outputDirectory>wso2cdm-${project.version}/modules/</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}/modules/</outputDirectory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>*/**</include>
|
<include>*/**</include>
|
||||||
</includes>
|
</includes>
|
||||||
@ -211,7 +211,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>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/dbscripts/cdm</directory>
|
||||||
<outputDirectory>wso2cdm-${project.version}/dbscripts/cdm</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}/dbscripts/cdm</outputDirectory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>*/**</include>
|
<include>*/**</include>
|
||||||
</includes>
|
</includes>
|
||||||
@ -226,7 +226,7 @@
|
|||||||
<!-- copy cdm jaggery app -->
|
<!-- copy cdm jaggery app -->
|
||||||
<fileSet>
|
<fileSet>
|
||||||
<directory>src/repository/jaggeryapps</directory>
|
<directory>src/repository/jaggeryapps</directory>
|
||||||
<outputDirectory>wso2cdm-${project.version}/repository/deployment/server/jaggeryapps
|
<outputDirectory>wso2mdm-${project.version}/repository/deployment/server/jaggeryapps
|
||||||
</outputDirectory>
|
</outputDirectory>
|
||||||
<fileMode>755</fileMode>
|
<fileMode>755</fileMode>
|
||||||
</fileSet>
|
</fileSet>
|
||||||
@ -234,13 +234,13 @@
|
|||||||
|
|
||||||
<dependencySets>
|
<dependencySets>
|
||||||
<dependencySet>
|
<dependencySet>
|
||||||
<outputDirectory>wso2cdm-${project.version}/lib/endorsed</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}/lib/endorsed</outputDirectory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>javax.el:el-api:jar</include>
|
<include>javax.el:el-api:jar</include>
|
||||||
</includes>
|
</includes>
|
||||||
</dependencySet>
|
</dependencySet>
|
||||||
<dependencySet>
|
<dependencySet>
|
||||||
<outputDirectory>wso2cdm-${project.version}/repository/deployment/client/modules
|
<outputDirectory>wso2mdm-${project.version}/repository/deployment/client/modules
|
||||||
</outputDirectory>
|
</outputDirectory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>org.hibernate.wso2:hibernate:jar</include>
|
<include>org.hibernate.wso2:hibernate:jar</include>
|
||||||
@ -252,13 +252,13 @@
|
|||||||
<files>
|
<files>
|
||||||
<file>
|
<file>
|
||||||
<source>../mobileservices/agents/android/jax-rs/target/cdm-android-api.war</source>
|
<source>../mobileservices/agents/android/jax-rs/target/cdm-android-api.war</source>
|
||||||
<outputDirectory>wso2cdm-${pom.version}/repository/deployment/server/webapps
|
<outputDirectory>wso2mdm-${pom.version}/repository/deployment/server/webapps
|
||||||
</outputDirectory>
|
</outputDirectory>
|
||||||
<fileMode>755</fileMode>
|
<fileMode>755</fileMode>
|
||||||
</file>
|
</file>
|
||||||
<file>
|
<file>
|
||||||
<source>../rest-api/target/wso2cdm-api.war</source>
|
<source>../rest-api/target/wso2cdm-api.war</source>
|
||||||
<outputDirectory>wso2cdm-${pom.version}/repository/deployment/server/webapps
|
<outputDirectory>wso2mdm-${pom.version}/repository/deployment/server/webapps
|
||||||
</outputDirectory>
|
</outputDirectory>
|
||||||
<fileMode>755</fileMode>
|
<fileMode>755</fileMode>
|
||||||
</file>
|
</file>
|
||||||
@ -280,7 +280,7 @@
|
|||||||
</file>-->
|
</file>-->
|
||||||
<file>
|
<file>
|
||||||
<source>src/repository/conf/tomcat/context.xml</source>
|
<source>src/repository/conf/tomcat/context.xml</source>
|
||||||
<outputDirectory>wso2cdm-${project.version}/repository/conf/tomcat</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}/repository/conf/tomcat</outputDirectory>
|
||||||
<filtered>true</filtered>
|
<filtered>true</filtered>
|
||||||
<fileMode>644</fileMode>
|
<fileMode>644</fileMode>
|
||||||
</file>
|
</file>
|
||||||
@ -294,37 +294,37 @@
|
|||||||
|
|
||||||
<file>
|
<file>
|
||||||
<source>INSTALL.txt</source>
|
<source>INSTALL.txt</source>
|
||||||
<outputDirectory>wso2cdm-${project.version}</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}</outputDirectory>
|
||||||
<filtered>true</filtered>
|
<filtered>true</filtered>
|
||||||
<fileMode>644</fileMode>
|
<fileMode>644</fileMode>
|
||||||
</file>
|
</file>
|
||||||
<file>
|
<file>
|
||||||
<source>README.txt</source>
|
<source>README.txt</source>
|
||||||
<outputDirectory>wso2cdm-${project.version}</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}</outputDirectory>
|
||||||
<filtered>true</filtered>
|
<filtered>true</filtered>
|
||||||
<fileMode>644</fileMode>
|
<fileMode>644</fileMode>
|
||||||
</file>
|
</file>
|
||||||
<file>
|
<file>
|
||||||
<source>LICENSE.txt</source>
|
<source>LICENSE.txt</source>
|
||||||
<outputDirectory>wso2cdm-${project.version}</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}</outputDirectory>
|
||||||
<filtered>true</filtered>
|
<filtered>true</filtered>
|
||||||
<fileMode>644</fileMode>
|
<fileMode>644</fileMode>
|
||||||
</file>
|
</file>
|
||||||
<file>
|
<file>
|
||||||
<source>release-notes.html</source>
|
<source>release-notes.html</source>
|
||||||
<outputDirectory>wso2cdm-${project.version}</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}</outputDirectory>
|
||||||
<filtered>true</filtered>
|
<filtered>true</filtered>
|
||||||
<fileMode>644</fileMode>
|
<fileMode>644</fileMode>
|
||||||
</file>
|
</file>
|
||||||
<file>
|
<file>
|
||||||
<source>target/wso2carbon-core-${carbon.kernel.version}/bin/README.txt</source>
|
<source>target/wso2carbon-core-${carbon.kernel.version}/bin/README.txt</source>
|
||||||
<outputDirectory>wso2cdm-${project.version}/bin/</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}/bin/</outputDirectory>
|
||||||
<filtered>true</filtered>
|
<filtered>true</filtered>
|
||||||
<fileMode>644</fileMode>
|
<fileMode>644</fileMode>
|
||||||
</file>
|
</file>
|
||||||
<file>
|
<file>
|
||||||
<source>target/wso2carbon-core-${carbon.kernel.version}/bin/version.txt</source>
|
<source>target/wso2carbon-core-${carbon.kernel.version}/bin/version.txt</source>
|
||||||
<outputDirectory>wso2cdm-${project.version}/bin/</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}/bin/</outputDirectory>
|
||||||
<filtered>true</filtered>
|
<filtered>true</filtered>
|
||||||
<fileMode>644</fileMode>
|
<fileMode>644</fileMode>
|
||||||
</file>
|
</file>
|
||||||
@ -334,7 +334,7 @@
|
|||||||
<source>
|
<source>
|
||||||
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/etc/logging-config.xml
|
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/etc/logging-config.xml
|
||||||
</source>
|
</source>
|
||||||
<outputDirectory>wso2cdm-${project.version}/repository/conf/etc</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}/repository/conf/etc</outputDirectory>
|
||||||
<filtered>true</filtered>
|
<filtered>true</filtered>
|
||||||
<fileMode>644</fileMode>
|
<fileMode>644</fileMode>
|
||||||
</file>
|
</file>
|
||||||
@ -344,7 +344,7 @@
|
|||||||
<source>
|
<source>
|
||||||
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/event-broker.xml
|
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/event-broker.xml
|
||||||
</source>
|
</source>
|
||||||
<outputDirectory>wso2cdm-${project.version}/repository/conf</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}/repository/conf</outputDirectory>
|
||||||
<filtered>true</filtered>
|
<filtered>true</filtered>
|
||||||
<fileMode>644</fileMode>
|
<fileMode>644</fileMode>
|
||||||
</file>
|
</file>
|
||||||
@ -354,7 +354,7 @@
|
|||||||
<source>
|
<source>
|
||||||
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/security/application-authentication.xml
|
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/security/application-authentication.xml
|
||||||
</source>
|
</source>
|
||||||
<outputDirectory>wso2cdm-${project.version}/repository/conf/security</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}/repository/conf/security</outputDirectory>
|
||||||
<filtered>true</filtered>
|
<filtered>true</filtered>
|
||||||
<fileMode>644</fileMode>
|
<fileMode>644</fileMode>
|
||||||
</file>
|
</file>
|
||||||
@ -364,14 +364,14 @@
|
|||||||
<source>
|
<source>
|
||||||
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/thrift-authentication.xml
|
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/thrift-authentication.xml
|
||||||
</source>
|
</source>
|
||||||
<outputDirectory>wso2cdm-${project.version}/repository/conf</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}/repository/conf</outputDirectory>
|
||||||
<filtered>true</filtered>
|
<filtered>true</filtered>
|
||||||
<fileMode>644</fileMode>
|
<fileMode>644</fileMode>
|
||||||
</file>
|
</file>
|
||||||
|
|
||||||
<file>
|
<file>
|
||||||
<source>src/repository/conf/multitenancy/cloud-services-desc.xml</source>
|
<source>src/repository/conf/multitenancy/cloud-services-desc.xml</source>
|
||||||
<outputDirectory>wso2cdm-${project.version}/repository/conf/multitenancy/
|
<outputDirectory>wso2mdm-${project.version}/repository/conf/multitenancy/
|
||||||
</outputDirectory>
|
</outputDirectory>
|
||||||
<filtered>true</filtered>
|
<filtered>true</filtered>
|
||||||
</file>
|
</file>
|
||||||
@ -383,19 +383,19 @@
|
|||||||
</file>-->
|
</file>-->
|
||||||
<file>
|
<file>
|
||||||
<source>src/repository/conf/application-authenticators.xml</source>
|
<source>src/repository/conf/application-authenticators.xml</source>
|
||||||
<outputDirectory>wso2cdm-${project.version}/repository/conf/security/</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}/repository/conf/security/</outputDirectory>
|
||||||
<filtered>true</filtered>
|
<filtered>true</filtered>
|
||||||
<fileMode>644</fileMode>
|
<fileMode>644</fileMode>
|
||||||
</file>
|
</file>
|
||||||
<file>
|
<file>
|
||||||
<source>target/wso2carbon-core-${carbon.kernel.version}/repository/conf/README</source>
|
<source>target/wso2carbon-core-${carbon.kernel.version}/repository/conf/README</source>
|
||||||
<outputDirectory>wso2cdm-${project.version}/repository/conf/</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}/repository/conf/</outputDirectory>
|
||||||
<filtered>true</filtered>
|
<filtered>true</filtered>
|
||||||
<fileMode>644</fileMode>
|
<fileMode>644</fileMode>
|
||||||
</file>
|
</file>
|
||||||
<file>
|
<file>
|
||||||
<source>src/repository/conf/identity.xml</source>
|
<source>src/repository/conf/identity.xml</source>
|
||||||
<outputDirectory>wso2cdm-${project.version}/repository/conf</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}/repository/conf</outputDirectory>
|
||||||
<fileMode>644</fileMode>
|
<fileMode>644</fileMode>
|
||||||
</file>
|
</file>
|
||||||
|
|
||||||
@ -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>
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
<!-- Copying p2 profile and osgi bundles-->
|
<!-- Copying p2 profile and osgi bundles-->
|
||||||
<fileSet>
|
<fileSet>
|
||||||
<directory>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/components</directory>
|
<directory>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/components</directory>
|
||||||
<outputDirectory>wso2cdm-${project.version}/repository/components</outputDirectory>
|
<outputDirectory>wso2mdm-${project.version}/repository/components</outputDirectory>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>**/eclipse.ini</exclude>
|
<exclude>**/eclipse.ini</exclude>
|
||||||
<exclude>**/*.lock</exclude>
|
<exclude>**/*.lock</exclude>
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
product.name=WSO2 Connected Device Manager
|
product.name=WSO2 Mobile Device Manager
|
||||||
product.version=2.0.0-SNAPSHOT
|
product.version=1.0.0-SNAPSHOT
|
||||||
product.key=CDM
|
product.key=MDM
|
||||||
hotdeployment=true
|
hotdeployment=true
|
||||||
hotupdate=true
|
hotupdate=true
|
||||||
carbon.version=4.3.0
|
carbon.version=4.3.0
|
||||||
default.server.role=CDMPlatform
|
default.server.role=MDMPlatform
|
||||||
|
|||||||
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,9 @@ 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 ,
|
||||||
|
`STATUS` VARCHAR(10) NOT 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` )
|
||||||
|
|||||||
@ -46,6 +46,7 @@ CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPPING` (
|
|||||||
`OPERATION_ID` INT NOT NULL,
|
`OPERATION_ID` INT NOT NULL,
|
||||||
`SENT_DATE` INT NULL,
|
`SENT_DATE` INT NULL,
|
||||||
`RECEIVED_DATE` INT NULL,
|
`RECEIVED_DATE` INT NULL,
|
||||||
|
`STATUS` VARCHAR(10) NOT NULL,
|
||||||
PRIMARY KEY (`DEVICE_ID`, `OPERATION_ID`),
|
PRIMARY KEY (`DEVICE_ID`, `OPERATION_ID`),
|
||||||
INDEX `fk_MBL_DEVICE_OPERATION_MBL_OPERATION1_idx` (`OPERATION_ID` ASC),
|
INDEX `fk_MBL_DEVICE_OPERATION_MBL_OPERATION1_idx` (`OPERATION_ID` ASC),
|
||||||
CONSTRAINT `fk_MBL_DEVICE_OPERATION_MBL_DEVICE`
|
CONSTRAINT `fk_MBL_DEVICE_OPERATION_MBL_DEVICE`
|
||||||
|
|||||||
@ -0,0 +1,39 @@
|
|||||||
|
<%
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var verb = request.getMethod();
|
||||||
|
var uri = request.getRequestURI();
|
||||||
|
var callPath=uri.replace("/cdm/api/","");
|
||||||
|
var log = new Log();
|
||||||
|
var deviceModule = require("/modules/device.js");
|
||||||
|
if (uri != null) {
|
||||||
|
var uriMatcher = new URIMatcher(callPath);
|
||||||
|
log.info(callPath);
|
||||||
|
if (uriMatcher.match("devices/mobile/{type}/{deviceid}/")) {
|
||||||
|
var deviceId = uriMatcher.elements().deviceid;
|
||||||
|
var type = uriMatcher.elements().type;
|
||||||
|
var result = deviceModule.viewDevice(type, deviceId);
|
||||||
|
print(result);
|
||||||
|
}
|
||||||
|
if (uriMatcher.match("devices/mobile/")) {
|
||||||
|
var result = deviceModule.listDevices();
|
||||||
|
print(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%>
|
||||||
@ -1,6 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
function identifierFormatter(value, row, index) {
|
function identifierFormatter(value, row, index) {
|
||||||
return [
|
return [
|
||||||
'<a class="like" href="/cdm/devices/'+value+'" title="Like">',
|
'<a class="like" href="/cdm/devices/' + row["deviceType"] + '/' + value + '" title="Like">',
|
||||||
value,
|
value,
|
||||||
'</a>'
|
'</a>'
|
||||||
].join('');}
|
].join('');
|
||||||
|
}
|
||||||
@ -1 +1,32 @@
|
|||||||
//Init js to execute
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
//Init js to execute
|
||||||
|
var logger = new Log();
|
||||||
|
logger.debug("running debug");
|
||||||
|
var app_TENANT_CONFIGS = 'tenant.configs';
|
||||||
|
var app_carbon = require('carbon');
|
||||||
|
var app_configs = {
|
||||||
|
"HTTPS_URL": "https://localhost:9443"
|
||||||
|
};
|
||||||
|
|
||||||
|
var app_server = new app_carbon.server.Server({
|
||||||
|
tenanted: app_configs.tenanted,
|
||||||
|
url: app_configs.HTTPS_URL + '/admin'
|
||||||
|
});
|
||||||
|
application.put("SERVER", app_server);
|
||||||
|
application.put(app_TENANT_CONFIGS, {});
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"welcomeFiles": ["pages/dashboard.jag"],
|
"welcomeFiles": ["pages/dashboard.jag"],
|
||||||
"initScripts": ["init.js"],
|
"initScripts": ["/init.js"],
|
||||||
"urlMappings": [
|
"urlMappings": [
|
||||||
{
|
{
|
||||||
"url": "/devices/*",
|
"url": "/devices/*",
|
||||||
@ -9,12 +9,16 @@
|
|||||||
{
|
{
|
||||||
"url": "/dashboard",
|
"url": "/dashboard",
|
||||||
"path": "/pages/dashboard.jag"
|
"path": "/pages/dashboard.jag"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "/api/devices/mobile/*",
|
||||||
|
"path": "/api/mobile/device-api.jag"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"errorPages": {
|
"errorPages": {
|
||||||
"500": "/error500.jag",
|
"500": "/error500.jag",
|
||||||
"404": "/error404.jag",
|
"404": "/error404.jag",
|
||||||
"403": "/error403.jag"
|
"403": "/error403.jag "
|
||||||
},
|
},
|
||||||
"logLevel": "info"
|
"logLevel": "debug"
|
||||||
}
|
}
|
||||||
@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var utility = require("/modules/utility.js");
|
||||||
|
var DeviceIdentifier = Packages.org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
|
var log = new Log();
|
||||||
|
|
||||||
|
var deviceManagementService = utility.getDeviceManagementService();
|
||||||
|
|
||||||
|
var listDevices = function () {
|
||||||
|
var devices = deviceManagementService.getAllDevices("android");
|
||||||
|
var deviceList = [];
|
||||||
|
|
||||||
|
for (i = 0; i < devices.size(); i++) {
|
||||||
|
var device = devices.get(i);
|
||||||
|
deviceList.push({
|
||||||
|
"identifier": device.getDeviceIdentifier(),
|
||||||
|
"name": device.getName(),
|
||||||
|
"ownership": device.getOwnership(),
|
||||||
|
"owner": device.getOwner(),
|
||||||
|
"deviceType": device.getType(),
|
||||||
|
"vendor": device.getProperties().get("vendor"),
|
||||||
|
"model": device.getProperties().get("model"),
|
||||||
|
"osVersion": device.getProperties().get("osVersion")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return deviceList;
|
||||||
|
}
|
||||||
|
var getDevice = function(type, deviceId){
|
||||||
|
var deviceIdentifier = new DeviceIdentifier();
|
||||||
|
deviceIdentifier.setType(type);
|
||||||
|
deviceIdentifier.setId(deviceId);
|
||||||
|
var device = deviceManagementService.getDevice(deviceIdentifier);
|
||||||
|
return device;
|
||||||
|
}
|
||||||
|
|
||||||
|
var viewDevice = function(type, deviceId){
|
||||||
|
var device = this.getDevice(type, deviceId);
|
||||||
|
|
||||||
|
var entries = device.getProperties().entrySet();
|
||||||
|
var iterator = entries.iterator();
|
||||||
|
var properties = {};
|
||||||
|
while(iterator.hasNext()){
|
||||||
|
var entry = iterator.next();
|
||||||
|
var key = entry.getKey();
|
||||||
|
var value = entry.getValue();
|
||||||
|
properties[key]= value;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
"identifier": device.getDeviceIdentifier(),
|
||||||
|
"name": device.getName(),
|
||||||
|
"ownership": device.getOwnership(),
|
||||||
|
"owner": device.getOwner(),
|
||||||
|
"deviceType": device.getType(),
|
||||||
|
"vendor": device.getProperties().get("vendor"),
|
||||||
|
"model": device.getProperties().get("model"),
|
||||||
|
"osVersion": device.getProperties().get("osVersion"),
|
||||||
|
"properties": properties
|
||||||
|
};
|
||||||
|
}
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//temporary
|
||||||
|
|
||||||
|
var PrivilegedCarbonContext = Packages.org.wso2.carbon.context.PrivilegedCarbonContext,
|
||||||
|
Class = java.lang.Class;
|
||||||
|
|
||||||
|
osgiService = function (clazz) {
|
||||||
|
return PrivilegedCarbonContext.getThreadLocalCarbonContext().getOSGiService(Class.forName(clazz));
|
||||||
|
};
|
||||||
|
var getDeviceManagementService= function(){
|
||||||
|
//server.authenticate("admin", "admin");
|
||||||
|
var realmService = osgiService('org.wso2.carbon.device.mgt.core.service.DeviceManagementService');
|
||||||
|
//var realmService = null;
|
||||||
|
return realmService;
|
||||||
|
}
|
||||||
@ -1,5 +1,22 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<%
|
<%
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
var title="WSO2 CDM";
|
var title="WSO2 CDM";
|
||||||
%>
|
%>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
@ -14,25 +31,43 @@ var title="WSO2 CDM";
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-9 main col-centered">
|
<div class="col-sm-9 main col-centered">
|
||||||
<h2 class="sub-header">Devices list</h2>
|
<h2 class="sub-header">Devices list</h2>
|
||||||
|
<!--
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-1"><button type="button" class="btn btn-primary">Execute</button></div>
|
<div class="col-md-1"><button type="button" class="btn btn-primary">Execute</button></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="table-responsive">
|
-->
|
||||||
<table id="table-pagination" data-toggle="table" data-url="data2.json" data-query-params="queryParams" data-height="400" data-pagination="true" data-search="true">
|
<div role="devicepanel">
|
||||||
<thead>
|
|
||||||
<tr>
|
<!-- Nav tabs -->
|
||||||
<th data-field="state" data-checkbox="true"></th>
|
<ul class="nav nav-tabs" role="tablist">
|
||||||
<th data-field="identifier" data-align="right" data-sortable="true" data-formatter="identifierFormatter">Identifier</th>
|
<li role="presentation" class="active"><a href="#mobile" aria-controls="home" role="tab" data-toggle="tab">Mobile</a></li>
|
||||||
<th data-field="name" data-align="center" data-sortable="true">Name</th>
|
<li role="presentation"><a href="#raspberrypi" aria-controls="profile" role="tab" data-toggle="tab">RaspberryPi</a></li>
|
||||||
<th data-field="owner" data-align="center" data-sortable="true">Owner</th>
|
</ul>
|
||||||
<th data-field="ownership" data-align="center" data-sortable="true">Ownership</th>
|
|
||||||
<th data-field="deviceType" data-align="center" data-sortable="true">Device Type</th>
|
<!-- Tab panes -->
|
||||||
<th data-field="vendor" data-align="center" data-sortable="true">Vendor</th>
|
<div class="tab-content">
|
||||||
<th data-field="model" data-align="center" data-sortable="true">Model</th>
|
<div role="devicepanel" class="tab-pane active" id="mobile">
|
||||||
<th data-field="osVersion" data-align="center" data-sortable="true">OS Version</th>
|
<div class="table-responsive">
|
||||||
</tr>
|
<table id="table-pagination" data-toggle="table" data-url="/cdm/api/devices/mobile" data-query-params="queryParams" data-height="400" data-pagination="true" data-search="true">
|
||||||
</thead>
|
<thead>
|
||||||
</table>
|
<tr>
|
||||||
|
<th data-field="state" data-checkbox="true"></th>
|
||||||
|
<th data-field="identifier" data-align="right" data-sortable="true" data-formatter="identifierFormatter">Identifier</th>
|
||||||
|
<th data-field="name" data-align="center" data-sortable="true">Name</th>
|
||||||
|
<th data-field="owner" data-align="center" data-sortable="true">Owner</th>
|
||||||
|
<th data-field="ownership" data-align="center" data-sortable="true">Ownership</th>
|
||||||
|
<th data-field="deviceType" data-align="center" data-sortable="true">Device Type</th>
|
||||||
|
<th data-field="vendor" data-align="center" data-sortable="true">Vendor</th>
|
||||||
|
<th data-field="model" data-align="center" data-sortable="true">Model</th>
|
||||||
|
<th data-field="osVersion" data-align="center" data-sortable="true">OS Version</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div role="devicepanel" class="tab-pane" id="raspberrypi">sdfweroiweuroi</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,5 +1,22 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<%
|
<%
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
var title="WSO2 CDM";
|
var title="WSO2 CDM";
|
||||||
%>
|
%>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
@ -9,11 +26,20 @@ var title="WSO2 CDM";
|
|||||||
<body>
|
<body>
|
||||||
<%
|
<%
|
||||||
include("/includes/header.jag");
|
include("/includes/header.jag");
|
||||||
|
|
||||||
|
var deviceModule = require("/modules/device.js");
|
||||||
|
var uri = request.getRequestURI();
|
||||||
|
var callPath=uri.replace("/cdm/","");
|
||||||
|
var uriMatcher = new URIMatcher(callPath);
|
||||||
|
uriMatcher.match("devices/{type}/{deviceid}/");
|
||||||
|
var deviceId = uriMatcher.elements().deviceid;
|
||||||
|
var type = uriMatcher.elements().type;
|
||||||
|
var device = deviceModule.viewDevice(type, deviceId);
|
||||||
%>
|
%>
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-9 main col-centered">
|
<div class="col-sm-9 main col-centered">
|
||||||
<h2 class="sub-header">Dulitha's iPhone</h2>
|
<h2 class="sub-header"><%=device.name%></h2>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -33,36 +59,44 @@ var title="WSO2 CDM";
|
|||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12 well well-lg device-static-data">
|
<div class="col-md-12 well well-lg device-static-data">
|
||||||
<p>Model: <span>GT-I9500</span> </p>
|
|
||||||
<p>IMSI : <span>GT-I9500</span> </p>
|
<%
|
||||||
<p>IMEI : <span>GT-I9500</span> </p>
|
for (var property in device.properties) {
|
||||||
</div>
|
if (device.properties.hasOwnProperty(property)) {
|
||||||
</div>
|
var value = device.properties[property];
|
||||||
<div class="row">
|
%>
|
||||||
<div class="col-md-12 well well-lg device-static-data">
|
<p><%=property %>: <span><%=value %></span> </p>
|
||||||
<p>Model: <span>GT-I9500</span> </p>
|
<%
|
||||||
<p>IMSI : <span>GT-I9500</span> </p>
|
}
|
||||||
<p>IMEI : <span>GT-I9500</span> </p>
|
}
|
||||||
</div>
|
%>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
</div>
|
||||||
<div class="col-md-12 well well-lg device-static-data">
|
<div class="row">
|
||||||
<table id="table-pagination" data-toggle="table" data-url="/cdm/data3.json" data-query-params="queryParams" data-height="300" data-pagination="true" data-search="true">
|
<div class="col-md-12 well well-lg device-static-data">
|
||||||
<thead>
|
<p>Model: <span>GT-I9500</span> </p>
|
||||||
<tr>
|
<p>IMSI : <span>GT-I9500</span> </p>
|
||||||
<th data-field="appName" data-align="right" data-sortable="true">App name</th>
|
<p>IMEI : <span>GT-I9500</span> </p>
|
||||||
<th data-field="packageName" data-align="center" data-sortable="true">Package name</th>
|
</div>
|
||||||
</tr>
|
</div>
|
||||||
</thead>
|
<div class="row">
|
||||||
</table>
|
<div class="col-md-12 well well-lg device-static-data">
|
||||||
</div>
|
<table id="table-pagination" data-toggle="table" data-url="/cdm/data3.json" data-query-params="queryParams" data-height="300" data-pagination="true" data-search="true">
|
||||||
</div>
|
<thead>
|
||||||
</div>
|
<tr>
|
||||||
</div>
|
<th data-field="appName" data-align="right" data-sortable="true">App name</th>
|
||||||
</div>
|
<th data-field="packageName" data-align="center" data-sortable="true">Package name</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<%
|
</div>
|
||||||
|
</div>
|
||||||
|
<%
|
||||||
include("/includes/layout-footer.jag");
|
include("/includes/layout-footer.jag");
|
||||||
%>
|
%>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@ -21,8 +21,8 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.wso2.cdmserver</groupId>
|
<groupId>org.wso2.mdmserver</groupId>
|
||||||
<artifactId>wso2cdmserver-product</artifactId>
|
<artifactId>wso2mdmserver-product</artifactId>
|
||||||
<version>2.0.0-SNAPSHOT</version>
|
<version>2.0.0-SNAPSHOT</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.wso2.cdmserver</groupId>
|
<groupId>org.wso2.mdmserver</groupId>
|
||||||
<artifactId>cdm-integration-tests-common</artifactId>
|
<artifactId>cdm-integration-tests-common</artifactId>
|
||||||
<version>2.0.0-SNAPSHOT</version>
|
<version>2.0.0-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.wso2.cdmserver</groupId>
|
<groupId>org.wso2.mdmserver</groupId>
|
||||||
<artifactId>cdm-integration-tests-common</artifactId>
|
<artifactId>cdm-integration-tests-common</artifactId>
|
||||||
<version>2.0.0-SNAPSHOT</version>
|
<version>2.0.0-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.wso2.cdmserver</groupId>
|
<groupId>org.wso2.mdmserver</groupId>
|
||||||
<artifactId>wso2cdm-integration</artifactId>
|
<artifactId>wso2cdm-integration</artifactId>
|
||||||
<version>2.0.0-SNAPSHOT</version>
|
<version>2.0.0-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.wso2.cdmserver</groupId>
|
<groupId>org.wso2.mdmserver</groupId>
|
||||||
<artifactId>cdm-integration-tests-common</artifactId>
|
<artifactId>cdm-integration-tests-common</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>WSO2 CDM Integration Test Common</name>
|
<name>WSO2 CDM Integration Test Common</name>
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.wso2.cdmserver</groupId>
|
<groupId>org.wso2.mdmserver</groupId>
|
||||||
<artifactId>cdm-integration-tests-common</artifactId>
|
<artifactId>cdm-integration-tests-common</artifactId>
|
||||||
<version>2.0.0-SNAPSHOT</version>
|
<version>2.0.0-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
|||||||
@ -21,8 +21,8 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.wso2.cdmserver</groupId>
|
<groupId>org.wso2.mdmserver</groupId>
|
||||||
<artifactId>wso2cdmserver-product-mobileservices</artifactId>
|
<artifactId>wso2mdmserver-product-mobileservices</artifactId>
|
||||||
<version>2.0.0-SNAPSHOT</version>
|
<version>2.0.0-SNAPSHOT</version>
|
||||||
<relativePath>../../../pom.xml</relativePath>
|
<relativePath>../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|||||||
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,7 +39,7 @@ public class Operation {
|
|||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
public List<org.wso2.carbon.device.mgt.common.Operation> getAllOperations(
|
public List<org.wso2.carbon.device.mgt.common.Operation> getPendingOperations(
|
||||||
@PathParam("id") String id)
|
@PathParam("id") String id)
|
||||||
throws AndroidAgentException {
|
throws AndroidAgentException {
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ public class Operation {
|
|||||||
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
||||||
operations = dmService.getOperationManager(
|
operations = dmService.getOperationManager(
|
||||||
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID)
|
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID)
|
||||||
.getOperations(deviceIdentifier);
|
.getPendingOperations(deviceIdentifier);
|
||||||
Response.status(HttpStatus.SC_OK);
|
Response.status(HttpStatus.SC_OK);
|
||||||
return operations;
|
return operations;
|
||||||
} catch (DeviceManagementServiceException deviceMgtServiceEx) {
|
} catch (DeviceManagementServiceException deviceMgtServiceEx) {
|
||||||
|
|||||||
@ -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>
|
||||||
|
|||||||
@ -1,75 +0,0 @@
|
|||||||
<!--
|
|
||||||
~ Copyright 2005-2007 WSO2, Inc. (http://wso2.com)
|
|
||||||
~
|
|
||||||
~ 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.
|
|
||||||
-->
|
|
||||||
<project default="build-all">
|
|
||||||
|
|
||||||
<property name="wso2appserver.home" value="../../../"/>
|
|
||||||
<property name="repo.location" value="${wso2appserver.home}/repository/deployment/server"/>
|
|
||||||
<property name="warName" value="jaxrs_basic.war"/>
|
|
||||||
<property name="build.dir" value="build"/>
|
|
||||||
<property name="classes" value="${build.dir}/classes"/>
|
|
||||||
<property name="lib" value="${build.dir}/lib"/>
|
|
||||||
<property name="webapps" value="${build.dir}/webapps"/>
|
|
||||||
<property name="src" value="."/>
|
|
||||||
|
|
||||||
<path id="compile.classpath">
|
|
||||||
<fileset dir="${lib}">
|
|
||||||
<include name="*.jar"/>
|
|
||||||
</fileset>
|
|
||||||
</path>
|
|
||||||
|
|
||||||
<target name="init" depends="clean">
|
|
||||||
<mkdir dir="${build.dir}"/>
|
|
||||||
<mkdir dir="${classes}"/>
|
|
||||||
<mkdir dir="${webapps}"/>
|
|
||||||
<mkdir dir="${lib}"/>
|
|
||||||
|
|
||||||
<copy toDir="${lib}">
|
|
||||||
<fileset dir="${wso2appserver.home}/repository/components/plugins/">
|
|
||||||
<include name="commons-httpclient_3.1.0.wso2v2.jar"/>
|
|
||||||
<include name="commons-codec_1.4.0.wso2v1.jar"/>
|
|
||||||
</fileset>
|
|
||||||
<fileset dir="${wso2appserver.home}/lib/runtimes/cxf/">
|
|
||||||
<include name="*.jar"/>
|
|
||||||
</fileset>
|
|
||||||
</copy>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="compile" depends="init" >
|
|
||||||
<javac destdir="${classes}" debug="true" srcdir="src">
|
|
||||||
<classpath refid="compile.classpath"/>
|
|
||||||
</javac>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="war" depends="compile">
|
|
||||||
<echo message="Creating webapp ${warName}."/>
|
|
||||||
<copy file="src/main/java/demo/jaxrs/client/add_customer.xml" todir="${classes}/demo/jaxrs/client"/>
|
|
||||||
<copy file="src/main/java/demo/jaxrs/client/update_customer.xml" todir="${classes}/demo/jaxrs/client"/>
|
|
||||||
<war destfile="${webapps}/${warName}" webxml="./src/main/webapp/WEB-INF/web.xml">
|
|
||||||
<classes dir="${classes}"/>
|
|
||||||
<fileset dir="src/main/webapp/"/>
|
|
||||||
</war>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="build-all" depends ="war">
|
|
||||||
<echo message="Copying the created war file in to the deployment directory"/>
|
|
||||||
<copy file="${webapps}/${warName}" todir="${repo.location}/webapps"/>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="clean">
|
|
||||||
<delete dir="${build.dir}" />
|
|
||||||
</target>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@ -1,26 +1,28 @@
|
|||||||
<!--
|
<!--
|
||||||
~ Copyright 2011-2012 WSO2, Inc. (http://wso2.com)
|
~ Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
~
|
~
|
||||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
~ you may not use this file except in compliance with the 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
|
~ You may obtain a copy of the License at
|
||||||
~
|
~
|
||||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
~
|
~
|
||||||
~ Unless required by applicable law or agreed to in writing, software
|
~ Unless required by applicable law or agreed to in writing,
|
||||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
~ software distributed under the License is distributed on an
|
||||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
~ See the License for the specific language governing permissions and
|
~ KIND, either express or implied. See the License for the
|
||||||
~ limitations under the License.
|
~ specific language governing permissions and limitations
|
||||||
-->
|
~ under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.wso2.cdmserver</groupId>
|
<groupId>org.wso2.mdmserver</groupId>
|
||||||
<artifactId>wso2cdmserver-product-mobileservices</artifactId>
|
<artifactId>wso2mdmserver-product-mobileservices</artifactId>
|
||||||
<version>2.0.0-SNAPSHOT</version>
|
<version>2.0.0-SNAPSHOT</version>
|
||||||
<relativePath>../../../pom.xml</relativePath>
|
<relativePath>../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
@ -127,23 +129,11 @@
|
|||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>commons-httpclient</groupId>
|
|
||||||
<artifactId>commons-httpclient</artifactId>
|
|
||||||
<version>3.1</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.ws.rs</groupId>
|
<groupId>javax.ws.rs</groupId>
|
||||||
<artifactId>jsr311-api</artifactId>
|
<artifactId>jsr311-api</artifactId>
|
||||||
<version>1.1.1</version>
|
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.code.gson</groupId>
|
|
||||||
<artifactId>gson</artifactId>
|
|
||||||
<version>2.2.4</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.wso2.carbon</groupId>
|
<groupId>org.wso2.carbon</groupId>
|
||||||
<artifactId>org.wso2.carbon.utils</artifactId>
|
<artifactId>org.wso2.carbon.utils</artifactId>
|
||||||
@ -152,13 +142,11 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.wso2.carbon</groupId>
|
<groupId>org.wso2.carbon</groupId>
|
||||||
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||||
<version>2.0.0-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.wso2.carbon</groupId>
|
<groupId>org.wso2.carbon</groupId>
|
||||||
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
|
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
|
||||||
<version>2.0.0-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -167,9 +155,9 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>org.apache.wss4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>wss4j-ws-security-common</artifactId>
|
||||||
<version>1.2.17</version>
|
<version>2.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bouncycastle</groupId>
|
<groupId>org.bouncycastle</groupId>
|
||||||
@ -181,10 +169,24 @@
|
|||||||
<artifactId>bcprov-jdk15on</artifactId>
|
<artifactId>bcprov-jdk15on</artifactId>
|
||||||
<version>1.49</version>
|
<version>1.49</version>
|
||||||
</dependency>
|
</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>org.apache.cxf</groupId>
|
||||||
|
<artifactId>cxf-rt-ws-security</artifactId>
|
||||||
|
<version>2.6.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.codehaus.jackson</groupId>
|
||||||
|
<artifactId>jackson-jaxrs</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
|
||||||
<cxf.version>2.6.1</cxf.version>
|
|
||||||
<junit.version>4.8.2</junit.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@ -1,81 +0,0 @@
|
|||||||
@echo off
|
|
||||||
REM ---------------------------------------------------------------------------
|
|
||||||
REM Copyright 2005,2006 WSO2, Inc. http://www.wso2.org
|
|
||||||
REM
|
|
||||||
REM Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
REM you may not use this file except in compliance with the License.
|
|
||||||
REM You may obtain a copy of the License at
|
|
||||||
REM
|
|
||||||
REM http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
REM
|
|
||||||
REM Unless required by applicable law or agreed to in writing, software
|
|
||||||
REM distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
REM See the License for the specific language governing permissions and
|
|
||||||
REM limitations under the License.
|
|
||||||
|
|
||||||
rem ---------------------------------------------------------------------------
|
|
||||||
rem Client script for the Jaxws-Jaxrs/jaxrs_basic Sample
|
|
||||||
rem
|
|
||||||
rem Environment Variable Prequisites
|
|
||||||
rem
|
|
||||||
rem WSO2AppServer_HOME Must point at your WSO2 AppServer directory
|
|
||||||
rem
|
|
||||||
rem JAVA_HOME Must point at your Java Development Kit installation.
|
|
||||||
rem
|
|
||||||
rem JAVA_OPTS (Optional) Java runtime options
|
|
||||||
rem ---------------------------------------------------------------------------
|
|
||||||
set CURRENT_DIR=%cd%
|
|
||||||
|
|
||||||
rem Make sure prerequisite environment variables are set
|
|
||||||
if not "%JAVA_HOME%" == "" goto gotJavaHome
|
|
||||||
echo The JAVA_HOME environment variable is not defined
|
|
||||||
echo This environment variable is needed to run this program
|
|
||||||
goto end
|
|
||||||
:gotJavaHome
|
|
||||||
if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
|
|
||||||
goto okJavaHome
|
|
||||||
:noJavaHome
|
|
||||||
echo The JAVA_HOME environment variable is not defined correctly
|
|
||||||
echo This environment variable is needed to run this program
|
|
||||||
echo NB: JAVA_HOME should point to a JDK/JRE
|
|
||||||
goto end
|
|
||||||
:okJavaHome
|
|
||||||
|
|
||||||
rem check the WSO2AppServer_HOME environment variable
|
|
||||||
if not "%WSO2AppServer_HOME%" == "" goto gotHome
|
|
||||||
set WSO2AppServer_HOME=%CURRENT_DIR%
|
|
||||||
if exist "%WSO2AppServer_HOME\bin\version.txt" goto okHome
|
|
||||||
|
|
||||||
rem guess the home. Jump two directories up to check if that is the home
|
|
||||||
cd ..\..\..
|
|
||||||
set WSO2AppServer_HOME=%cd%
|
|
||||||
cd %CURRENT_DIR%
|
|
||||||
|
|
||||||
:gotHome
|
|
||||||
if exist "%WSO2AppServer_HOME%\bin\version.txt" goto okHome
|
|
||||||
|
|
||||||
set WSO2AppServer_HOME=%~dp0..\..
|
|
||||||
if exist "%WSO2AppServer_HOME%\bin\version.txt" goto okHome
|
|
||||||
|
|
||||||
echo The WSO2AppServer_HOME environment variable is not defined correctly
|
|
||||||
echo This environment variable is needed to run this program
|
|
||||||
goto end
|
|
||||||
|
|
||||||
:okHome
|
|
||||||
rem set the classes
|
|
||||||
setlocal EnableDelayedExpansion
|
|
||||||
rem loop through the libs and add them to the class path
|
|
||||||
cd %WSO2AppServer_HOME%\samples\Jaxws-Jaxrs\jaxrs_basic
|
|
||||||
set CLIENT_CLASSPATH=.\conf;.\build\classes
|
|
||||||
FOR %%C in (.\build\lib\*.jar) DO set CLIENT_CLASSPATH=!CLIENT_CLASSPATH!;.\build\lib\%%~nC%%~xC
|
|
||||||
|
|
||||||
rem ----- Execute The Requested Command ---------------------------------------
|
|
||||||
echo Using WSO2AppServer_HOME: %WSO2AppServer_HOME%
|
|
||||||
echo Using JAVA_HOME: %JAVA_HOME%
|
|
||||||
set _RUNJAVA="%JAVA_HOME%\bin\java"
|
|
||||||
|
|
||||||
%_RUNJAVA% %JAVA_OPTS% -Dwso2appserver.home="%WSO2AppServer_HOME%" -cp "%CLIENT_CLASSPATH%" -Djava.endorsed.dirs="%WSO2AppServer_HOME%\lib\endorsed";"%JAVA_HOME%\jre\lib\endorsed";"%JAVA_HOME%\lib\endorsed" demo.jaxrs.client.Client http://localhost:9763/jaxrs_basic/services/customers/customerservice %*
|
|
||||||
cd %CURRENT_DIR%
|
|
||||||
endlocal
|
|
||||||
:end
|
|
||||||
@ -1,90 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
# Environment Variable Prequisites
|
|
||||||
#
|
|
||||||
# CARBON_HOME Home of WSO2 AppServer installation. If not set I will try
|
|
||||||
# to figure it out.
|
|
||||||
#
|
|
||||||
# JAVA_HOME Must point at your Java Development Kit installation.
|
|
||||||
#
|
|
||||||
# NOTE: Borrowed generously from Apache Tomcat startup scripts.
|
|
||||||
|
|
||||||
# if JAVA_HOME is not set we're not happy
|
|
||||||
if [ -z "$JAVA_HOME" ]; then
|
|
||||||
echo "You must set the JAVA_HOME variable before running WSO2 AppServer."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# OS specific support. $var _must_ be set to either true or false.
|
|
||||||
cygwin=false
|
|
||||||
os400=false
|
|
||||||
case "`uname`" in
|
|
||||||
CYGWIN*) cygwin=true;;
|
|
||||||
OS400*) os400=true;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# resolve links - $0 may be a softlink
|
|
||||||
PRG="$0"
|
|
||||||
|
|
||||||
while [ -h "$PRG" ]; do
|
|
||||||
ls=`ls -ld "$PRG"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '.*/.*' > /dev/null; then
|
|
||||||
PRG="$link"
|
|
||||||
else
|
|
||||||
PRG=`dirname "$PRG"`/"$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Get standard environment variables
|
|
||||||
PRGDIR=`dirname "$PRG"`
|
|
||||||
|
|
||||||
# Only set WSO2AppServer_HOME if not already set
|
|
||||||
[ -z "$CARBON_HOME" ] && CARBON_HOME=`cd "$PRGDIR/../../.." ; pwd`
|
|
||||||
|
|
||||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
|
||||||
if $cygwin; then
|
|
||||||
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
|
||||||
[ -n "$CARBON_HOME" ] && WSO2AppServer_HOME=`cygpath --unix "$CARBON_HOME"`
|
|
||||||
[ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For OS400
|
|
||||||
if $os400; then
|
|
||||||
# Set job priority to standard for interactive (interactive - 6) by using
|
|
||||||
# the interactive priority - 6, the helper threads that respond to requests
|
|
||||||
# will be running at the same priority as interactive jobs.
|
|
||||||
COMMAND='chgjob job('$JOBNAME') runpty(6)'
|
|
||||||
system $COMMAND
|
|
||||||
|
|
||||||
# Enable multi threading
|
|
||||||
QIBM_MULTI_THREADED=Y
|
|
||||||
export QIBM_MULTI_THREADED
|
|
||||||
fi
|
|
||||||
|
|
||||||
# update classpath
|
|
||||||
CLIENT_CLASSPATH=""
|
|
||||||
for f in "$CARBON_HOME"/samples/Jaxws-Jaxrs/jaxrs_basic/build/lib/*.jar
|
|
||||||
do
|
|
||||||
CLIENT_CLASSPATH=$CLIENT_CLASSPATH:$f
|
|
||||||
done
|
|
||||||
CLIENT_CLASSPATH=$CLIENT_CLASSPATH:$CLASSPATH
|
|
||||||
|
|
||||||
|
|
||||||
# For Cygwin, switch paths to Windows format before running java
|
|
||||||
if $cygwin; then
|
|
||||||
JAVA_HOME=`cygpath --absolute --windows "$JAVA_HOME"`
|
|
||||||
CARBON_HOME=`cygpath --absolute --windows "$CARBON_HOME"`
|
|
||||||
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
|
|
||||||
JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"`
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo Using CARBON_HOME: $CARBON_HOME
|
|
||||||
echo Using JAVA_HOME : $JAVA_HOME
|
|
||||||
|
|
||||||
CLIENT_CLASSPATH="$CARBON_HOME/samples/Jaxws-Jaxrs/jaxrs_basic/build/classes":$CLIENT_CLASSPATH
|
|
||||||
|
|
||||||
$JAVA_HOME/bin/java -Dwso2appserver.home="$CARBON_HOME" -classpath "$CLIENT_CLASSPATH" \
|
|
||||||
-Djava.endorsed.dirs="$CARBON_HOME/lib/endorsed":"$JAVA_HOME/jre/lib/endorsed":"$JAVA_HOME/lib/endorsed" \
|
|
||||||
demo.jaxrs.client.Client http://localhost:9763/jaxrs_basic/services/customers/customerservice$*
|
|
||||||
@ -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);
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* 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.DiscoveryService;
|
||||||
|
|
||||||
|
|
||||||
|
import cdm.api.windows.DiscoveryService.beans.in.DiscoveryRequest;
|
||||||
|
import cdm.api.windows.DiscoveryService.beans.out.Message;
|
||||||
|
|
||||||
|
import javax.jws.WebMethod;
|
||||||
|
import javax.jws.WebParam;
|
||||||
|
import javax.jws.WebResult;
|
||||||
|
import javax.jws.WebService;
|
||||||
|
import javax.ws.rs.*;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
import javax.xml.ws.BindingType;
|
||||||
|
import javax.xml.ws.RequestWrapper;
|
||||||
|
import javax.xml.ws.ResponseWrapper;
|
||||||
|
import javax.xml.ws.soap.SOAPBinding;
|
||||||
|
|
||||||
|
@WebService(targetNamespace = "http://schemas.microsoft.com/windows/management/2012/01/enrollment", name = "IDiscoveryService")
|
||||||
|
@BindingType(value = SOAPBinding.SOAP12HTTP_BINDING)
|
||||||
|
public interface DiscoveryServiceGet {
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@WebMethod(operationName = "Discover")
|
||||||
|
@RequestWrapper(targetNamespace = "http://schemas.microsoft.com/windows/management/2012/01/enrollment")
|
||||||
|
@ResponseWrapper(targetNamespace = "http://schemas.microsoft.com/windows/management/2012/01/enrollment")
|
||||||
|
@WebResult(name = "DiscoverResult") Message Discover(
|
||||||
|
@WebParam(name = "request")
|
||||||
|
DiscoveryRequest request);
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@WebMethod
|
||||||
|
@WebResult() Response DiscoverGet();
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* 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.DiscoveryService.beans.in;
|
||||||
|
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.*;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@XmlRootElement
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
public class DiscoveryRequest implements Serializable {
|
||||||
|
|
||||||
|
@XmlElement(name = "EmailAddress")
|
||||||
|
private String emailId;
|
||||||
|
|
||||||
|
@XmlElement(name = "RequestVersion")
|
||||||
|
private String version;
|
||||||
|
|
||||||
|
@XmlElement(name = "DeviceType")
|
||||||
|
private String deviceType;
|
||||||
|
|
||||||
|
public String getEmailId() {
|
||||||
|
return emailId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmailId(String emailId) {
|
||||||
|
this.emailId = emailId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVersion(String version) {
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeviceType() {
|
||||||
|
return deviceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceType(String deviceType) {
|
||||||
|
this.deviceType = deviceType;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@javax.xml.bind.annotation.XmlSchema(namespace = "http://schemas.microsoft.com/windows/pki/2009/01/enrollment", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
|
||||||
|
package cdm.api.windows.DiscoveryService.beans.in;
|
||||||
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* 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.DiscoveryService.beans.out;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.*;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
|
||||||
|
@XmlRootElement
|
||||||
|
public class Message implements Serializable {
|
||||||
|
|
||||||
|
private String authPolicy;
|
||||||
|
private String enrollmentPolicyServiceUrl;
|
||||||
|
private String enrollmentServiceUrl;
|
||||||
|
|
||||||
|
@XmlElement(name = "AuthPolicy", namespace = "http://schemas.microsoft.com/windows/management/2012/01/enrollment")
|
||||||
|
public String getAuthPolicy() {
|
||||||
|
return authPolicy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "EnrollmentPolicyServiceUrl", namespace = "http://schemas.microsoft.com/windows/management/2012/01/enrollment")
|
||||||
|
public String getEnrollmentPolicyServiceUrl() {
|
||||||
|
return enrollmentPolicyServiceUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "EnrollmentServiceUrl", namespace = "http://schemas.microsoft.com/windows/management/2012/01/enrollment")
|
||||||
|
public String getEnrollmentServiceUrl() {
|
||||||
|
return enrollmentServiceUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthPolicy(String authPolicy) {
|
||||||
|
this.authPolicy = authPolicy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnrollmentPolicyServiceUrl(String enrollmentPolicyServiceUrl) {
|
||||||
|
this.enrollmentPolicyServiceUrl = enrollmentPolicyServiceUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnrollmentServiceUrl(String enrollmentServiceUrl) {
|
||||||
|
this.enrollmentServiceUrl = enrollmentServiceUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* 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.DiscoveryService.impl;
|
||||||
|
|
||||||
|
import cdm.api.windows.DiscoveryService.beans.in.DiscoveryRequest;
|
||||||
|
import cdm.api.windows.DiscoveryService.DiscoveryServiceGet;
|
||||||
|
import cdm.api.windows.DiscoveryService.beans.out.Message;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import javax.jws.WebService;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
import javax.xml.ws.BindingType;
|
||||||
|
import javax.xml.ws.soap.Addressing;
|
||||||
|
import javax.xml.ws.soap.SOAPBinding;
|
||||||
|
|
||||||
|
@WebService(endpointInterface = "cdm.api.windows.DiscoveryService.DiscoveryServiceGet", targetNamespace = "http://schemas.microsoft.com/windows/management/2012/01/enrollment")
|
||||||
|
@Addressing(enabled = true, required = true)
|
||||||
|
@BindingType(value = SOAPBinding.SOAP12HTTP_BINDING)
|
||||||
|
public class DiscoveryServiceGetImpl implements DiscoveryServiceGet {
|
||||||
|
|
||||||
|
private Logger LOGGER = Logger.getLogger(DiscoveryServiceGetImpl.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Message Discover(DiscoveryRequest disRequest) {
|
||||||
|
|
||||||
|
System.out.println("CHECK_SECOND_POST");
|
||||||
|
|
||||||
|
Message message = new Message();
|
||||||
|
message.setAuthPolicy("OnPremise");
|
||||||
|
|
||||||
|
message.setEnrollmentPolicyServiceUrl(
|
||||||
|
"https://EnterpriseEnrollment.wso2.com/ENROLLMENTSERVER/PolicyEnrollmentWebservice.svc");
|
||||||
|
message.setEnrollmentServiceUrl(
|
||||||
|
"https://EnterpriseEnrollment.wso2.com/ENROLLMENTSERVER/DeviceEnrollmentWebservice.svc");
|
||||||
|
|
||||||
|
LOGGER.info("Received Discovery Service Request");
|
||||||
|
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Response DiscoverGet() {
|
||||||
|
|
||||||
|
System.out.println("CHECK_FIRST_GET");
|
||||||
|
|
||||||
|
return Response.ok().build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* 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.wstep;
|
||||||
|
|
||||||
|
import cdm.api.windows.wstep.beans.RequestSecurityTokenResponse;
|
||||||
|
|
||||||
|
import javax.jws.WebMethod;
|
||||||
|
import javax.jws.WebParam;
|
||||||
|
import javax.jws.WebResult;
|
||||||
|
import javax.jws.WebService;
|
||||||
|
import javax.ws.rs.*;
|
||||||
|
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||||
|
import javax.xml.ws.Action;
|
||||||
|
import javax.xml.ws.RequestWrapper;
|
||||||
|
import javax.xml.ws.ResponseWrapper;
|
||||||
|
import javax.xml.ws.soap.SOAPBinding;
|
||||||
|
import javax.xml.ws.BindingType;
|
||||||
|
|
||||||
|
@WebService(targetNamespace = "http://schemas.microsoft.com/windows/pki/2009/01/enrollment/RSTRC", name = "wstep")
|
||||||
|
@BindingType(value = SOAPBinding.SOAP12HTTP_BINDING)
|
||||||
|
public interface CertificateEnrollmentService {
|
||||||
|
|
||||||
|
@RequestWrapper(localName = "RequestSecurityToken", targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512")
|
||||||
|
@WebMethod(operationName = "RequestSecurityToken")
|
||||||
|
@ResponseWrapper(localName = "RequestSecurityTokenResponseCollection", targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512")
|
||||||
|
public void RequestSecurityToken(
|
||||||
|
@WebParam(name = "TokenType", targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512")
|
||||||
|
String TokenType,
|
||||||
|
@WebParam(name = "RequestType", targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512")
|
||||||
|
String RequestType,
|
||||||
|
@WebParam(name = "BinarySecurityToken", targetNamespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd")
|
||||||
|
String BinarySecurityToken,
|
||||||
|
@WebParam(name = "AdditionalContext", targetNamespace = "http://schemas.xmlsoap.org/ws/2006/12/authorization")
|
||||||
|
cdm.api.windows.wstep.beans.AdditionalContext AdditionalContext,
|
||||||
|
@WebParam(mode = WebParam.Mode.OUT, name = "RequestSecurityTokenResponse", targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512")
|
||||||
|
javax.xml.ws.Holder<RequestSecurityTokenResponse> response
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* 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.wstep.beans;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlType;
|
||||||
|
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
@XmlType(name = "OIDCollection", namespace = "http://schemas.xmlsoap.org/ws/2006/12/authorization", propOrder = {
|
||||||
|
"contextitem"
|
||||||
|
})
|
||||||
|
public class AdditionalContext {
|
||||||
|
|
||||||
|
@XmlElement(name = "ContextItem", required = true)
|
||||||
|
protected List<ContextItem> contextitem;
|
||||||
|
|
||||||
|
public List<ContextItem> getcontextitem() {
|
||||||
|
if (contextitem == null) {
|
||||||
|
contextitem = new ArrayList<ContextItem>();
|
||||||
|
}
|
||||||
|
return this.contextitem;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* 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.wstep.beans;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.*;
|
||||||
|
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
@XmlType(name = "BinarySecurityToken", namespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd")
|
||||||
|
public class BinarySecurityToken {
|
||||||
|
|
||||||
|
@XmlAttribute(name = "ValueType")
|
||||||
|
protected String ValueType;
|
||||||
|
@XmlAttribute(name = "EncodingType")
|
||||||
|
protected String EncodingType;
|
||||||
|
|
||||||
|
@XmlValue
|
||||||
|
protected String Token;
|
||||||
|
|
||||||
|
public void setValueType(String valuetype) {
|
||||||
|
this.ValueType = valuetype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValueType() {
|
||||||
|
return this.ValueType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEncodingType(String encodingtype) {
|
||||||
|
this.EncodingType = encodingtype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEncodingType() {
|
||||||
|
return this.EncodingType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setToken(String token) {
|
||||||
|
this.Token = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getToken() {
|
||||||
|
return this.Token;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* 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.wstep.beans;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlType;
|
||||||
|
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
@XmlType(name = "ContextItem", namespace = "http://schemas.xmlsoap.org/ws/2006/12/authorization", propOrder = {
|
||||||
|
"Value"
|
||||||
|
})
|
||||||
|
public class ContextItem {
|
||||||
|
|
||||||
|
@XmlElement(required = true)
|
||||||
|
protected String Value;
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* 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.wstep.beans;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlType;
|
||||||
|
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
@XmlType(name = "RequestedSecurityToken", namespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512", propOrder = {
|
||||||
|
"binarySecurityToken"
|
||||||
|
})
|
||||||
|
public class RequestSecurityToken {
|
||||||
|
|
||||||
|
@XmlElement(name = "BinarySecurityToken", required = true, namespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd")
|
||||||
|
|
||||||
|
protected BinarySecurityToken binarySecurityToken;
|
||||||
|
|
||||||
|
public void setBinarySecurityToken(BinarySecurityToken binarysecuritytoken) {
|
||||||
|
this.binarySecurityToken = binarysecuritytoken;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* 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.wstep.beans;
|
||||||
|
|
||||||
|
import cdm.api.windows.wstep.beans.AdditionalContext;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlType;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
@XmlType(name = "RequestSecurityTokenResponse", namespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512", propOrder = {
|
||||||
|
"TokenType",
|
||||||
|
"RequestedSecurityToken",
|
||||||
|
"RequestID"
|
||||||
|
})
|
||||||
|
public class RequestSecurityTokenResponse implements Serializable {
|
||||||
|
|
||||||
|
@XmlElement(name = "TokenType", namespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512")
|
||||||
|
private String TokenType;
|
||||||
|
|
||||||
|
@XmlElement(name = "RequestedSecurityToken", required = true, namespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512")
|
||||||
|
private RequestedSecurityToken RequestedSecurityToken;
|
||||||
|
|
||||||
|
@XmlElement(name = "RequestID", namespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512")
|
||||||
|
private int RequestID;
|
||||||
|
|
||||||
|
public String getTokenType() {
|
||||||
|
return TokenType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTokenType(String tokenType) {
|
||||||
|
TokenType = tokenType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RequestedSecurityToken getRequestedSecurityToken() {
|
||||||
|
return RequestedSecurityToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequestedSecurityToken(RequestedSecurityToken requestedSecurityToken) {
|
||||||
|
RequestedSecurityToken = requestedSecurityToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRequestID() {
|
||||||
|
return RequestID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequestID(int requestID) {
|
||||||
|
RequestID = requestID;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* 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.wstep.beans;
|
||||||
|
|
||||||
|
import cdm.api.windows.wstep.beans.ContextItem;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlType;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
@XmlType(name = "RequestedSecurityToken", namespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512", propOrder = {
|
||||||
|
"binarySecurityToken"
|
||||||
|
})
|
||||||
|
public class RequestedSecurityToken {
|
||||||
|
|
||||||
|
@XmlElement(name = "BinarySecurityToken", required = true, namespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd")
|
||||||
|
|
||||||
|
protected BinarySecurityToken binarySecurityToken;
|
||||||
|
|
||||||
|
public void setBinarySecurityToken(BinarySecurityToken binarysecuritytoken) {
|
||||||
|
this.binarySecurityToken = binarysecuritytoken;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@XmlSchema(namespace = "http://www.w3.org/2003/05/soap-envelope",
|
||||||
|
xmlns = {
|
||||||
|
@XmlNs(prefix = "", namespaceURI = "http://www.w3.org/2003/05/soap-envelope")
|
||||||
|
}, elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
|
||||||
|
|
||||||
|
package cdm.api.windows.wstep.beans;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlNs;
|
||||||
|
import javax.xml.bind.annotation.XmlSchema;
|
||||||
@ -0,0 +1,195 @@
|
|||||||
|
/*
|
||||||
|
* 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.wstep.impl;
|
||||||
|
|
||||||
|
import cdm.api.windows.wstep.beans.AdditionalContext;
|
||||||
|
import cdm.api.windows.wstep.CertificateEnrollmentService;
|
||||||
|
import cdm.api.windows.wstep.beans.BinarySecurityToken;
|
||||||
|
import javax.jws.WebService;
|
||||||
|
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.ws.BindingType;
|
||||||
|
import javax.xml.ws.Holder;
|
||||||
|
import javax.xml.ws.soap.Addressing;
|
||||||
|
import javax.xml.ws.soap.SOAPBinding;
|
||||||
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
|
import cdm.api.windows.wstep.beans.RequestSecurityTokenResponse;
|
||||||
|
import cdm.api.windows.wstep.beans.RequestedSecurityToken;
|
||||||
|
import cdm.api.windows.wstep.util.CertificateSigningService;
|
||||||
|
import cdm.api.windows.wstep.util.KeyStoreGenerator;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.bouncycastle.pkcs.PKCS10CertificationRequest;
|
||||||
|
import org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequest;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.NamedNodeMap;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.NodeList;
|
||||||
|
import sun.misc.BASE64Encoder;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
import java.security.KeyStore;
|
||||||
|
import java.security.PrivateKey;
|
||||||
|
import java.security.cert.Certificate;
|
||||||
|
import java.security.cert.CertificateFactory;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
|
|
||||||
|
@WebService(endpointInterface = "cdm.api.windows.wstep.CertificateEnrollmentService", targetNamespace = "http://schemas.microsoft.com/windows/pki/2009/01/enrollment/RSTRC")
|
||||||
|
@Addressing(enabled = true, required = true)
|
||||||
|
@BindingType(value = SOAPBinding.SOAP12HTTP_BINDING)
|
||||||
|
public class CertificateEnrollmentServiceImpl implements CertificateEnrollmentService {
|
||||||
|
|
||||||
|
private Logger LOGGER = Logger.getLogger(CertificateEnrollmentServiceImpl.class);
|
||||||
|
|
||||||
|
PrivateKey privateKey;
|
||||||
|
X509Certificate rooCACertificate;
|
||||||
|
JcaPKCS10CertificationRequest csrReq;
|
||||||
|
PKCS10CertificationRequest certificationRequest;
|
||||||
|
|
||||||
|
String wapProvisioningXmlFile;
|
||||||
|
DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
|
||||||
|
|
||||||
|
@Override public void RequestSecurityToken(String TokenType, String RequestType,
|
||||||
|
String BinarySecurityToken,
|
||||||
|
AdditionalContext AdditionalContext,
|
||||||
|
Holder<RequestSecurityTokenResponse> response) {
|
||||||
|
|
||||||
|
certificateSign();
|
||||||
|
//////////
|
||||||
|
System.out.println("\n\n\n"+"REQUEST_CSR:"+BinarySecurityToken+"\n\n\n");
|
||||||
|
//////////
|
||||||
|
|
||||||
|
File file = new File(getClass().getClassLoader().getResource("wap-provisioning.xml").getFile());
|
||||||
|
wapProvisioningXmlFile = file.getPath();
|
||||||
|
|
||||||
|
String encodedWap="Initial_test";
|
||||||
|
|
||||||
|
RequestSecurityTokenResponse rs = new RequestSecurityTokenResponse();
|
||||||
|
rs.setTokenType(
|
||||||
|
"http://schemas.microsoft.com/5.0.0.0/ConfigurationManager/Enrollment/DeviceEnrollmentToken");
|
||||||
|
|
||||||
|
try {
|
||||||
|
byte[] derByteArray = javax.xml.bind.DatatypeConverter.parseBase64Binary(BinarySecurityToken);
|
||||||
|
certificationRequest = new PKCS10CertificationRequest(derByteArray);
|
||||||
|
csrReq = new JcaPKCS10CertificationRequest(certificationRequest);
|
||||||
|
|
||||||
|
X509Certificate signedCert = CertificateSigningService.signCSR(csrReq, privateKey, rooCACertificate);
|
||||||
|
|
||||||
|
System.out.println("PUBLIC KEY OF SIGNED CERT :"+signedCert.getPublicKey()+"\n\n\n");
|
||||||
|
System.out.println("PUBLIC KEY OF CSR :"+csrReq.getPublicKey()+"\n\n\n");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BASE64Encoder base64Encoder = new BASE64Encoder();
|
||||||
|
String rootCertEncodedString = base64Encoder.encode(rooCACertificate.getEncoded());
|
||||||
|
String signedCertEncoded = base64Encoder.encode(signedCert.getEncoded());
|
||||||
|
|
||||||
|
DocumentBuilder builder = domFactory.newDocumentBuilder();
|
||||||
|
Document dDoc = builder.parse(wapProvisioningXmlFile);
|
||||||
|
|
||||||
|
NodeList wapParm = dDoc.getElementsByTagName("parm");
|
||||||
|
/////////
|
||||||
|
wapParm.item(0).getParentNode().getAttributes().getNamedItem("type").setTextContent(String.valueOf(
|
||||||
|
DigestUtils.sha1Hex(rooCACertificate.getEncoded())));
|
||||||
|
/////////
|
||||||
|
NamedNodeMap rootCertAttributes = wapParm.item(0).getAttributes();
|
||||||
|
Node b64Encoded = rootCertAttributes.getNamedItem("value");
|
||||||
|
rootCertEncodedString=rootCertEncodedString.replaceAll("\n","");
|
||||||
|
b64Encoded.setTextContent(rootCertEncodedString);
|
||||||
|
System.out.println("COPY_ROOT_CERT:"+rootCertEncodedString);
|
||||||
|
|
||||||
|
/////////
|
||||||
|
wapParm.item(1).getParentNode().getAttributes().getNamedItem("type").setTextContent(String.valueOf(DigestUtils.sha1Hex(signedCert.getEncoded())));
|
||||||
|
/////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
NamedNodeMap clientCertAttributes = wapParm.item(1).getAttributes();
|
||||||
|
Node b64CliendEncoded = clientCertAttributes.getNamedItem("value");
|
||||||
|
signedCertEncoded=signedCertEncoded.replaceAll("\n","");
|
||||||
|
b64CliendEncoded.setTextContent(signedCertEncoded);
|
||||||
|
System.out.println("COPY_SIGNED_CERT:"+signedCertEncoded);
|
||||||
|
|
||||||
|
|
||||||
|
String wapProvisioning = convertDocumentToString(dDoc);
|
||||||
|
|
||||||
|
///////
|
||||||
|
System.out.println("WAP_XML:"+wapProvisioning+"\n\n\n");
|
||||||
|
///////
|
||||||
|
|
||||||
|
encodedWap = base64Encoder.encode(wapProvisioning.getBytes());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
//throw
|
||||||
|
}
|
||||||
|
|
||||||
|
RequestedSecurityToken rst = new RequestedSecurityToken();
|
||||||
|
BinarySecurityToken BinarySecToken=new BinarySecurityToken();
|
||||||
|
BinarySecToken.setValueType("http://schemas.microsoft.com/5.0.0.0/ConfigurationManager/Enrollment/DeviceEnrollmentProvisionDoc");
|
||||||
|
BinarySecToken.setEncodingType(
|
||||||
|
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd#base64binary");
|
||||||
|
BinarySecToken.setToken(encodedWap);
|
||||||
|
rst.setBinarySecurityToken(BinarySecToken);
|
||||||
|
|
||||||
|
rs.setRequestedSecurityToken(rst);
|
||||||
|
rs.setRequestID(0);
|
||||||
|
response.value = rs;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private String convertDocumentToString(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 certificateSign() {
|
||||||
|
|
||||||
|
try {
|
||||||
|
KeyStore securityJks = KeyStoreGenerator.getKeyStore();
|
||||||
|
String pass = "wso2carbon";
|
||||||
|
KeyStoreGenerator.loadToStore(securityJks, pass.toCharArray(), "/Users/asok/Downloads/wso2as-5.2.1/repository/resources/security/wso2carbon.jks");
|
||||||
|
PrivateKey privateKeyCA = (PrivateKey) securityJks.getKey("wso2carbon", pass.toCharArray());
|
||||||
|
|
||||||
|
privateKey=privateKeyCA;
|
||||||
|
|
||||||
|
Certificate cartificateCA = securityJks.getCertificate(pass);
|
||||||
|
CertificateFactory cf = CertificateFactory.getInstance("X.509");
|
||||||
|
ByteArrayInputStream bais = new ByteArrayInputStream(cartificateCA.getEncoded());
|
||||||
|
X509Certificate cartificateCAX509 = (X509Certificate) cf.generateCertificate(bais);
|
||||||
|
|
||||||
|
rooCACertificate=cartificateCAX509;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* 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.wstep.util;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom exception handling class, to handle the issue that come up during
|
||||||
|
* execution of Apk and certificate generation.
|
||||||
|
*/
|
||||||
|
public class ApkGenerationException extends Exception {
|
||||||
|
|
||||||
|
public ApkGenerationException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApkGenerationException(String message, Throwable e) {
|
||||||
|
super(message, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,104 @@
|
|||||||
|
package cdm.api.windows.wstep.util;
|
||||||
|
|
||||||
|
//REMOVE THIS LATER
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.bouncycastle.asn1.x500.X500Name;
|
||||||
|
import org.bouncycastle.asn1.x509.*;
|
||||||
|
import org.bouncycastle.cert.X509CertificateHolder;
|
||||||
|
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.crypto.params.AsymmetricKeyParameter;
|
||||||
|
import org.bouncycastle.crypto.util.PrivateKeyFactory;
|
||||||
|
import org.bouncycastle.jce.PKCS10CertificationRequest;
|
||||||
|
import org.bouncycastle.operator.ContentSigner;
|
||||||
|
import org.bouncycastle.operator.DefaultDigestAlgorithmIdentifierFinder;
|
||||||
|
import org.bouncycastle.operator.DefaultSignatureAlgorithmIdentifierFinder;
|
||||||
|
import org.bouncycastle.operator.OperatorCreationException;
|
||||||
|
import org.bouncycastle.operator.bc.BcRSAContentSignerBuilder;
|
||||||
|
import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
|
||||||
|
//import org.bouncycastle.pkcs.PKCS10CertificationRequestHolder;
|
||||||
|
import org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequest;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.security.*;
|
||||||
|
import java.security.cert.CertificateException;
|
||||||
|
import java.security.cert.CertificateFactory;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class CertificateSigningService {
|
||||||
|
|
||||||
|
private static Logger LOGGER = Logger.getLogger(CertificateSigningService.class);
|
||||||
|
|
||||||
|
/*public static X509Certificate sign(PKCS10CertificationRequest inputCSR, PrivateKey caPrivate, X509Certificate caCertificate)
|
||||||
|
throws InvalidKeyException, NoSuchAlgorithmException,NoSuchProviderException, SignatureException, IOException,
|
||||||
|
OperatorCreationException, CertificateException {
|
||||||
|
|
||||||
|
AlgorithmIdentifier sigAlgId = new DefaultSignatureAlgorithmIdentifierFinder().find("SHA1withRSA");
|
||||||
|
AlgorithmIdentifier digAlgId = new DefaultDigestAlgorithmIdentifierFinder().find(sigAlgId);
|
||||||
|
|
||||||
|
AsymmetricKeyParameter foo = PrivateKeyFactory.createKey(caPrivate.getEncoded());
|
||||||
|
|
||||||
|
//SubjectPublicKeyInfo keyInfo = SubjectPublicKeyInfo.getInstance(pair.getPublic().getEncoded());
|
||||||
|
|
||||||
|
PKCS10CertificationRequestHolder pk10Holder = new PKCS10CertificationRequestHolder(inputCSR);
|
||||||
|
SubjectPublicKeyInfo csrKeyInfo = pk10Holder.getSubjectPublicKeyInfo();
|
||||||
|
|
||||||
|
LOGGER.info("CN of the Device's CSR : " + pk10Holder.getSubject().toString());
|
||||||
|
|
||||||
|
|
||||||
|
X509v3CertificateBuilder myCertificateGenerator = new X509v3CertificateBuilder(
|
||||||
|
new X500Name(caCertificate.getIssuerX500Principal().getName()), 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"), csrKeyInfo);
|
||||||
|
|
||||||
|
ContentSigner sigGen = new BcRSAContentSignerBuilder(sigAlgId, digAlgId).build(foo);
|
||||||
|
|
||||||
|
X509CertificateHolder holder = myCertificateGenerator.build(sigGen);
|
||||||
|
X509CertificateStructure eeX509CertificateStructure = holder.toASN1Structure();
|
||||||
|
|
||||||
|
CertificateFactory cf = CertificateFactory.getInstance("X.509", "BC");
|
||||||
|
|
||||||
|
// Read Certificate
|
||||||
|
InputStream is1 = new ByteArrayInputStream(eeX509CertificateStructure.getEncoded());
|
||||||
|
X509Certificate theCert = (X509Certificate) cf.generateCertificate(is1);
|
||||||
|
|
||||||
|
LOGGER.info("Signed Certificate CN : " + theCert.getSubjectDN().getName());
|
||||||
|
|
||||||
|
LOGGER.info("Signed CSR's public key : " + theCert.getPublicKey());
|
||||||
|
|
||||||
|
is1.close();
|
||||||
|
return theCert;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* 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.wstep.util;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
import java.security.PrivateKey;
|
||||||
|
import java.security.PublicKey;
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
import java.security.cert.CertificateException;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
|
import java.util.Date;
|
||||||
|
import org.spongycastle.asn1.x500.X500Name;
|
||||||
|
import org.spongycastle.cert.X509v3CertificateBuilder;
|
||||||
|
import org.spongycastle.cert.jcajce.JcaX509CertificateConverter;
|
||||||
|
import org.spongycastle.cert.jcajce.JcaX509v3CertificateBuilder;
|
||||||
|
import org.spongycastle.operator.ContentSigner;
|
||||||
|
import org.spongycastle.operator.OperatorCreationException;
|
||||||
|
import org.spongycastle.operator.jcajce.JcaContentSignerBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate X509 V3 certificates. CA, RA and SSL can be generated, where
|
||||||
|
* intermediate certificates are signed from the root certificate to generate
|
||||||
|
* the chain.
|
||||||
|
*/
|
||||||
|
public class CertificateUtil {
|
||||||
|
private static final Log LOG = LogFactory.getLog(CertificateUtil.class);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static X509Certificate signCSR(PublicKey publicKeyToBeSigned, PrivateKey caPrivateKey, X509Certificate caCert) throws Exception{
|
||||||
|
try {
|
||||||
|
X509v3CertificateBuilder certificateBuilder = new JcaX509v3CertificateBuilder(caCert,
|
||||||
|
BigInteger
|
||||||
|
.valueOf(new SecureRandom().nextInt(Integer.MAX_VALUE)),
|
||||||
|
new Date(System.currentTimeMillis()),
|
||||||
|
new Date(System.currentTimeMillis() + (1000L * 60 * 60 * 24 * 365*10)),
|
||||||
|
new X500Name("CN=abimaran"),
|
||||||
|
publicKeyToBeSigned);
|
||||||
|
ContentSigner signer = new JcaContentSignerBuilder("SHA1withRSA").setProvider("SC").build(caPrivateKey);
|
||||||
|
X509Certificate theCert = new JcaX509CertificateConverter().setProvider("SC").getCertificate(certificateBuilder.build(signer));
|
||||||
|
return theCert;
|
||||||
|
|
||||||
|
} catch (OperatorCreationException e) {
|
||||||
|
String message = "Error creating ContentSigner with JcaContentSignerBuilder"
|
||||||
|
+ " with the private key provided.";
|
||||||
|
LOG.error(message, e);
|
||||||
|
throw new ApkGenerationException(message, e);
|
||||||
|
} catch (CertificateException e) {
|
||||||
|
String message = "Error building certificate.";
|
||||||
|
LOG.error(message, e);
|
||||||
|
throw new ApkGenerationException(message, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,117 @@
|
|||||||
|
/*
|
||||||
|
* 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.wstep.util;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constants used throughout the project
|
||||||
|
*/
|
||||||
|
public class Constants {
|
||||||
|
public static class FilePath {
|
||||||
|
private FilePath() {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String BKS_FILE = "emm_truststore.bks";
|
||||||
|
public static final String ANDROID_AGENT = "emm-agent-android";
|
||||||
|
public static final String WSO2CARBON_JKS = "wso2carbon.jks";
|
||||||
|
public static final String CLIENT_TRUST_JKS = "client-truststore.jks";
|
||||||
|
|
||||||
|
public static final String COMMON_UTIL = ANDROID_AGENT + File.separator + "src" +
|
||||||
|
File.separator + "org" + File.separator + "wso2" +
|
||||||
|
File.separator + "emm" + File.separator + "agent" +
|
||||||
|
File.separator + "utils" + File.separator +
|
||||||
|
"CommonUtilities.java";
|
||||||
|
public static final String WSO2EMM_JKS = "wso2emm.jks";
|
||||||
|
public static final String ANDROID_AGENT_RAW = ANDROID_AGENT + File.separator + "res" +
|
||||||
|
File.separator + "raw" + File.separator;
|
||||||
|
public static final String ANDROID_AGENT_APK = ANDROID_AGENT + File.separator + "target" +
|
||||||
|
File.separator + "emm_agent.apk";
|
||||||
|
public static final String APK_FOLDER = "Apk";
|
||||||
|
public static final String JKS_FOLDER = "jks";
|
||||||
|
public static final String BIN_PATH = File.separator + "bin" + File.separator + "mvn";
|
||||||
|
public static final String WORKING_DIR = "workingDir";
|
||||||
|
public static final String ZIP_PATH = "zipPath";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String ALGORITHM = "RSA";
|
||||||
|
public static final String PROVIDER = "SC";
|
||||||
|
public static final String ENCRYPTION = "SHA1withRSA";
|
||||||
|
public static final String REGISTRATION_AUTHORITY = "RA";
|
||||||
|
public static final String BKS = "BKS";
|
||||||
|
public static final String BKS_ALIAS = "cert-alias";
|
||||||
|
public static final String JKS = "JKS";
|
||||||
|
public static final String SSL = "SSL";
|
||||||
|
public static final String ENVIRONMENT_VARIABLE = "MAVEN_HOME";
|
||||||
|
public static final String ARCHIVE_TYPE = ".zip";
|
||||||
|
public static final String ACTION = "clean";
|
||||||
|
public static final String GOAL = "package";
|
||||||
|
public static final String SERVER_IP_ANDROID = "String SERVER_IP = \"";
|
||||||
|
public static final String TRUST_STORE_BKS = "String TRUSTSTORE_PASSWORD = \"";
|
||||||
|
|
||||||
|
public static class CSRDataKeys {
|
||||||
|
private CSRDataKeys() {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String COUNTRY_CA = "countryCA";
|
||||||
|
public static final String STATE_CA = "stateCA";
|
||||||
|
public static final String LOCALITY_CA = "localityCA";
|
||||||
|
public static final String ORGANIZATION_CA = "organizationCA";
|
||||||
|
public static final String ORGANIZATION_UNIT_CA = "organizationUCA";
|
||||||
|
public static final String DAYS_CA = "daysCA";
|
||||||
|
public static final String COMMON_NAME_CA = "commonNameCA";
|
||||||
|
public static final String COUNTRY_RA = "countryRA";
|
||||||
|
public static final String STATE_RA = "stateRA";
|
||||||
|
public static final String LOCALITY_RA = "localityRA";
|
||||||
|
public static final String ORGANIZATION_RA = "organizationRA";
|
||||||
|
public static final String ORGANIZATION_UNIT_RA = "organizationURA";
|
||||||
|
public static final String DAYS_RA = "daysRA";
|
||||||
|
public static final String COMMON_NAME_RA = "commonNameRA";
|
||||||
|
public static final String COUNTRY_SSL = "countrySSL";
|
||||||
|
public static final String STATE_SSL = "stateSSL";
|
||||||
|
public static final String LOCALITY_SSL = "localitySSL";
|
||||||
|
public static final String ORGANIZATION_SSL = "organizationSSL";
|
||||||
|
public static final String ORGANIZATION_UNIT_SSL = "organizationUSSL";
|
||||||
|
public static final String DAYS_SSL = "daysSSL";
|
||||||
|
public static final String SERVER_IP = "serverIp";
|
||||||
|
public static final String PASSWORD = "password";
|
||||||
|
public static final String USERSNAME = "usersname";
|
||||||
|
public static final String COMPANY = "company";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class TruststoreKeys {
|
||||||
|
private TruststoreKeys() {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String PASSWORD_PK12_CA = "passwordPK12CA";
|
||||||
|
public static final String PASSWORD_PK12_RA = "passwordPK12RA";
|
||||||
|
public static final String ALIAS_PK12_CA = "aliasPK12CA";
|
||||||
|
public static final String ALIAS_PK12_RA = "aliasPK12RA";
|
||||||
|
public static final String PASSWORD_WSO2_EMM_JKS = "passwordWSO2EMMJKS";
|
||||||
|
public static final String ALIAS__CLIENT_TRUSTSTORE = "aliasClientTruststore";
|
||||||
|
public static final String PASSWORD_CLIENT_TRUSTSTORE = "passwordClientTruststore";
|
||||||
|
public static final String ALIAS_WSO2_CARBON = "aliasWSO2Carbon";
|
||||||
|
public static final String PASSWORD_WSO2_CARBON = "passwordWSO2Carbon";
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user