adding API Everywhere related changes to device-mgt component

revert-dabc3590
prabathabey 10 years ago
commit fea3486084

@ -144,11 +144,11 @@ public class Device {
this.type = type;
}
@XmlElement
public List<Property> getProperties() {
public List<Device.Property> getProperties() {
return properties;
}
public void setProperties(List<Property> properties) {
public void setProperties(List<Device.Property> properties) {
this.properties = properties;
}

@ -54,7 +54,12 @@ public class DeviceManager implements DeviceManagerService {
boolean status = dms.enrollDevice(device);
try {
this.getDeviceTypeDAO().getDeviceType();
this.getDeviceDAO().addDevice(DeviceManagementDAOUtil.convertDevice(device));
org.wso2.carbon.device.mgt.core.dto.Device deviceDto = DeviceManagementDAOUtil.convertDevice(
device);
Integer deviceTypeId = this.getDeviceDAO().getDeviceTypeIdByDeviceTypeName(device.getType());
deviceDto.setDeviceType(deviceTypeId);
this.getDeviceDAO().addDevice(deviceDto);
} catch (DeviceManagementDAOException e) {
throw new DeviceManagementException("Error occurred while enrolling the device '" +
device.getId() + "'", e);

@ -37,4 +37,5 @@ public interface DeviceDAO {
List<Device> getDevices() throws DeviceManagementDAOException;
Integer getDeviceTypeIdByDeviceTypeName(String type) throws DeviceManagementDAOException;
}

@ -29,6 +29,7 @@ import org.wso2.carbon.device.mgt.core.dto.Status;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
import java.util.List;
@ -101,6 +102,38 @@ public class DeviceDAOImpl implements DeviceDAO {
return null;
}
@Override
public Integer getDeviceTypeIdByDeviceTypeName(String type) throws DeviceManagementDAOException {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet resultSet = null;
Integer deviceTypeId = null;
try {
conn = this.getConnection();
String createDBQuery =
"SELECT * From DM_DEVICE_TYPE DT WHERE DT.NAME=?";
stmt = conn.prepareStatement(createDBQuery);
stmt.setString(1, type);
resultSet = stmt.executeQuery();
while(resultSet.next()){
deviceTypeId = resultSet.getInt(1);
}
} catch (SQLException e) {
String msg = "Error occurred while fetch device type id for device type '" + type + "'";
log.error(msg, e);
throw new DeviceManagementDAOException(msg, e);
} finally {
DeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return deviceTypeId;
}
private Connection getConnection() throws DeviceManagementDAOException {
try {
return dataSource.getConnection();

@ -118,7 +118,7 @@ public final class DeviceManagementDAOUtil {
deviceBO.setOwnerId(device.getOwner());
deviceBO.setOwnerShip(device.getOwnership());
deviceBO.setTenantId(DeviceManagementDAOUtil.getTenantId());
//deviceBO.setDeviceType(Integer.parseInt(device.getType()));
deviceBO.setDeviceIdentificationId(device.getDeviceIdentifier());
return deviceBO;
}

@ -82,6 +82,14 @@
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi.services</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.apimgt.impl</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.apimgt.core</artifactId>
</dependency>
</dependencies>
</project>

@ -16,11 +16,17 @@
package org.wso2.carbon.device.mgt.mobile.impl.android;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService;
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileDevice;
import org.wso2.carbon.device.mgt.mobile.impl.util.MobileDeviceManagementUtil;
import java.util.List;
@ -29,6 +35,8 @@ import java.util.List;
*/
public class AndroidDeviceManagerService implements DeviceManagerService {
private static final Log log = LogFactory.getLog(AndroidDeviceManagerService.class);
@Override
public String getProviderType() {
return DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID;
@ -36,22 +44,64 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
@Override
public boolean enrollDevice(Device device) throws DeviceManagementException {
return true;
boolean status = false;
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
try {
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().addDevice(mobileDevice);
} catch (MobileDeviceManagementDAOException e) {
String msg = "Error while enrolling the Android device : " +
device.getDeviceIdentifier();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return status;
}
@Override
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
return true;
boolean status = false;
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
try {
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().updateDevice(mobileDevice);
} catch (MobileDeviceManagementDAOException e) {
String msg = "Error while updating the enrollment of the Android device : " +
device.getDeviceIdentifier();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return status;
}
@Override
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
return true;
boolean status = false;
try {
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().deleteDevice(deviceId.getId());
} catch (MobileDeviceManagementDAOException e) {
String msg = "Error while removing the Android device : " + deviceId.getId();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return status;
}
@Override
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
return true;
boolean isEnrolled = false;
try {
MobileDevice mobileDevice =
MobileDeviceManagementDAOFactory.getMobileDeviceDAO().getDevice(
deviceId.getId());
if(mobileDevice!=null){
isEnrolled = true;
}
} catch (MobileDeviceManagementDAOException e) {
String msg = "Error while checking the enrollment status of Android device : " +
deviceId.getId();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return isEnrolled;
}
@Override
@ -72,7 +122,17 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
@Override
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
return null;
Device device = null;
try {
MobileDevice mobileDevice = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().
getDevice(deviceId.getId());
device = MobileDeviceManagementUtil.convertToDevice(mobileDevice);
} catch (MobileDeviceManagementDAOException e) {
String msg = "Error while fetching the Android device : " + deviceId.getId();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return device;
}
@Override
@ -83,9 +143,15 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
@Override
public boolean updateDeviceInfo(Device device) throws DeviceManagementException {
return true;
boolean status = false;
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
try {
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().updateDevice(mobileDevice);
} catch (MobileDeviceManagementDAOException e) {
String msg = "Error while updating the Android device : " + device.getDeviceIdentifier();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return status;
}
//should implement equals and hashcode in all service bundles
}

@ -0,0 +1,98 @@
/**
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wso2.carbon.device.mgt.mobile.impl.config;
import org.wso2.carbon.apimgt.api.APIProvider;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
@XmlRootElement(name = "API")
public class APIConfig {
private String name;
private String owner;
private String context;
private String endpoint;
private String version;
private String transports;
private APIProvider provider;
public void init(APIProvider provider) {
this.provider = provider;
}
@XmlTransient
public APIProvider getProvider() {
return provider;
}
@XmlElement(name = "Name", nillable = false)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@XmlElement(name = "Owner", nillable = false)
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
@XmlElement(name = "Context", nillable = false)
public String getContext() {
return context;
}
public void setContext(String context) {
this.context = context;
}
@XmlElement(name = "Endpoint", nillable = false)
public String getEndpoint() {
return endpoint;
}
public void setEndpoint(String endpoint) {
this.endpoint = endpoint;
}
@XmlElement(name = "Version", nillable = false)
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
@XmlElement(name = "Transports", nillable = false)
public String getTransports() {
return transports;
}
public void setTransports(String transports) {
this.transports = transports;
}
}

@ -0,0 +1,36 @@
/**
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wso2.carbon.device.mgt.mobile.impl.config;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
@XmlRootElement(name = "APIPublisher")
public class APIPublisherConfig {
private List<APIConfig> apis;
@XmlElement(name = "APIs")
public List<APIConfig> getApis() {
return apis;
}
public void setApis(List<APIConfig> apis) {
this.apis = apis;
}
}

@ -18,7 +18,7 @@ package org.wso2.carbon.device.mgt.mobile.impl.config;
import org.w3c.dom.Document;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.mobile.impl.util.MobileDeviceManagerUtil;
import org.wso2.carbon.device.mgt.mobile.impl.util.MobileDeviceManagementUtil;
import org.wso2.carbon.device.mgt.mobile.impl.config.datasource.MobileDataSourceConfig;
import org.wso2.carbon.utils.CarbonUtils;
@ -53,7 +53,7 @@ public class MobileDeviceConfigurationManager {
public synchronized void initConfig() throws DeviceManagementException {
try {
File mobileDeviceMgtConfig = new File(mobileDeviceMgtConfigXMLPath);
Document doc = MobileDeviceManagerUtil.convertToDocument(mobileDeviceMgtConfig);
Document doc = MobileDeviceManagementUtil.convertToDocument(mobileDeviceMgtConfig);
JAXBContext mobileDeviceMgmtContext =
JAXBContext.newInstance(MobileDeviceManagementConfig.class);
Unmarshaller unmarshaller = mobileDeviceMgmtContext.createUnmarshaller();

@ -25,6 +25,7 @@ import javax.xml.bind.annotation.XmlRootElement;
public final class MobileDeviceManagementConfig {
private MobileDeviceManagementRepository mobileDeviceMgtRepository;
private APIPublisherConfig apiPublisherConfig;
@XmlElement(name = "ManagementRepository", nillable = false)
public MobileDeviceManagementRepository getMobileDeviceMgtRepository() {
@ -36,4 +37,13 @@ public final class MobileDeviceManagementConfig {
this.mobileDeviceMgtRepository = mobileDeviceMgtRepository;
}
@XmlElement(name = "APIPublisher")
public APIPublisherConfig getApiPublisherConfig() {
return apiPublisherConfig;
}
public void setApiPublisherConfig(APIPublisherConfig apiPublisherConfig) {
this.apiPublisherConfig = apiPublisherConfig;
}
}

@ -25,15 +25,15 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "DataSourceConfiguration")
public class MobileDataSourceConfig {
private JNDILookupDefinition jndiLookupDefintion;
private JNDILookupDefinition jndiLookupDefinition;
@XmlElement(name = "JndiLookupDefinition", nillable = true)
public JNDILookupDefinition getJndiLookupDefintion() {
return jndiLookupDefintion;
return jndiLookupDefinition;
}
public void setJndiLookupDefintion(JNDILookupDefinition jndiLookupDefintion) {
this.jndiLookupDefintion = jndiLookupDefintion;
public void setJndiLookupDefinition(JNDILookupDefinition jndiLookupDefinition) {
this.jndiLookupDefinition = jndiLookupDefinition;
}
}

@ -26,10 +26,10 @@ public interface MobileDeviceDAO {
MobileDevice getDevice(String deviceId) throws MobileDeviceManagementDAOException;
void addDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException;
boolean addDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException;
void updateDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException;
boolean updateDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException;
void deleteDevice(String deviceId) throws MobileDeviceManagementDAOException;
boolean deleteDevice(String deviceId) throws MobileDeviceManagementDAOException;
}

@ -1,57 +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 org.wso2.carbon.device.mgt.mobile.impl.dao;
import org.wso2.carbon.device.mgt.mobile.impl.DataSourceListener;
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileDeviceDAOImpl;
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileDeviceModelDAOImpl;
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileDeviceVendorDAOImpl;
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileOSVersionDAOImpl;
import org.wso2.carbon.device.mgt.mobile.impl.dao.util.MobileDeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.mobile.impl.internal.MobileDeviceManagementBundleActivator;
import javax.sql.DataSource;
public class MobileDeviceDAOFactory implements DataSourceListener {
private static DataSource dataSource;
public MobileDeviceDAOFactory() {
MobileDeviceManagementBundleActivator.registerDataSourceListener(this);
}
@Override
public void notifyObserver() {
dataSource = MobileDeviceManagementDAOUtil.resolveDataSource();
}
public static MobileDeviceDAO getMobileDeviceDAO() {
return new MobileDeviceDAOImpl(dataSource);
}
public static MobileDeviceModelDAO getMobileDeviceModelDAO() {
return new MobileDeviceModelDAOImpl(dataSource);
}
public static MobileDeviceVendorDAO getMobileDeviceVendorDAO() {
return new MobileDeviceVendorDAOImpl(dataSource);
}
public static MobileOSVersionDAO getMobileOSVersionDAO() {
return new MobileOSVersionDAOImpl(dataSource);
}
}

@ -18,87 +18,59 @@ package org.wso2.carbon.device.mgt.mobile.impl.dao;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.mobile.impl.DataSourceListener;
import org.wso2.carbon.device.mgt.mobile.impl.config.datasource.MobileDataSourceConfig;
import org.wso2.carbon.device.mgt.mobile.impl.config.datasource.JNDILookupDefinition;
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileDeviceDAOImpl;
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileDeviceModelDAOImpl;
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileDeviceVendorDAOImpl;
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileOSVersionDAOImpl;
import org.wso2.carbon.device.mgt.mobile.impl.dao.util.MobileDeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.mobile.impl.internal.MobileDeviceManagementBundleActivator;
import javax.sql.DataSource;
import java.util.Hashtable;
import java.util.List;
/**
* Factory class used to create MobileDeviceManagement related DAO objects.
*/
public class MobileDeviceManagementDAOFactory {
public class MobileDeviceManagementDAOFactory implements DataSourceListener {
private static DataSource dataSource;
private static MobileDataSourceConfig mobileDataSourceConfig;
private static final Log log = LogFactory.getLog(MobileDeviceManagementDAOFactory.class);
public static MobileDeviceDAO getMobileDeviceDAO() {
return new MobileDeviceDAOImpl(dataSource);
}
public MobileDeviceManagementDAOFactory() {
public static MobileDeviceModelDAO getMobileDeviceModelDAO() {
return new MobileDeviceModelDAOImpl(dataSource);
}
public static MobileDeviceVendorDAO getMobileDeviceVendorDAO() {
return new MobileDeviceVendorDAOImpl(dataSource);
public void init(){
dataSource = MobileDeviceManagementDAOUtil.resolveDataSource(mobileDataSourceConfig);
if(dataSource!=null){
MobileDeviceManagementDAOUtil.createDataSource(dataSource);
}else{
MobileDeviceManagementBundleActivator.registerDataSourceListener(this);
}
}
public static MobileOSVersionDAO getMobileOSVersionDAO() {
return new MobileOSVersionDAOImpl(dataSource);
public static MobileDeviceDAO getMobileDeviceDAO() {
return new MobileDeviceDAOImpl(dataSource);
}
public static void init(MobileDataSourceConfig config) {
dataSource = resolveDataSource(config);
public static MobileDataSourceConfig getMobileDeviceManagementConfig() {
return mobileDataSourceConfig;
}
public static void init(DataSource dtSource) {
dataSource = dtSource;
public static void setMobileDataSourceConfig(
MobileDataSourceConfig mobileDataSourceConfig) {
MobileDeviceManagementDAOFactory.mobileDataSourceConfig =
mobileDataSourceConfig;
}
/**
* Resolve data source from the data source definition
*
* @param config data source configuration
* @return data source resolved from the data source definition
*/
private static DataSource resolveDataSource(MobileDataSourceConfig config) {
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);
}
}
public static DataSource getDataSource() {
return dataSource;
}
public static DataSource getDataSource() {
return dataSource;
@Override
public void notifyObserver() {
dataSource = MobileDeviceManagementDAOUtil.resolveDataSource(mobileDataSourceConfig);
if(dataSource!=null){
MobileDeviceManagementDAOUtil.createDataSource(dataSource);
}
}
}

@ -1,34 +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 org.wso2.carbon.device.mgt.mobile.impl.dao;
import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileDeviceModel;
/**
* This class represents the key operations associated with persisting mobile-device model related
* information.
*/
public interface MobileDeviceModelDAO {
MobileDeviceModel getDeviceModel(String modelId) throws MobileDeviceManagementDAOException;
void addDeviceModel(MobileDeviceModel deviceModel) throws MobileDeviceManagementDAOException;
void updateDeviceModel(MobileDeviceModel deviceModel) throws MobileDeviceManagementDAOException;
void deleteDeviceModel(String modelId) throws MobileDeviceManagementDAOException;
}

@ -1,35 +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 org.wso2.carbon.device.mgt.mobile.impl.dao;
import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileDeviceVendor;
/**
* This class represents the key operations associated with persisting mobile-device vendor
* related information.
*/
public interface MobileDeviceVendorDAO {
MobileDeviceVendor getDeviceModel(String vendorId) throws MobileDeviceManagementDAOException;
void addDeviceVendor(MobileDeviceVendor deviceVendor) throws MobileDeviceManagementDAOException;
void updateDeviceVendor(MobileDeviceVendor deviceVendor)
throws MobileDeviceManagementDAOException;
void deleteDeviceVendor(String vendorId) throws MobileDeviceManagementDAOException;
}

@ -1,34 +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 org.wso2.carbon.device.mgt.mobile.impl.dao;
import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileOSVersion;
/**
* This class represents the key operations associated with persisting mobile-device OS version
* related information.
*/
public interface MobileOSVersionDAO {
MobileOSVersion getMobileOSVersion(String versionId) throws MobileDeviceManagementDAOException;
void addMobileOSVersion(MobileOSVersion osVersion) throws MobileDeviceManagementDAOException;
void updateMobileOSVersion(MobileOSVersion osVersion) throws MobileDeviceManagementDAOException;
void deleteMobileOSVersion(String versionId) throws MobileDeviceManagementDAOException;
}

@ -20,9 +20,14 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceDAO;
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.impl.dao.util.MobileDeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileDevice;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* Implementation of MobileDeviceDAO.
@ -38,23 +43,140 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
@Override
public MobileDevice getDevice(String deviceId) throws MobileDeviceManagementDAOException {
return null;
Connection conn = null;
PreparedStatement stmt = null;
MobileDevice mobileDevice = null;
try {
conn = this.getConnection();
String selectDBQuery =
"SELECT * FROM MBL_DEVICE WHERE MOBILE_DEVICE_ID = ?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, deviceId);
ResultSet resultSet = stmt.executeQuery();
while (resultSet.next()) {
mobileDevice = new MobileDevice();
mobileDevice.setMobileDeviceId(resultSet.getString(1));
mobileDevice.setRegId(resultSet.getString(2));
mobileDevice.setImei(resultSet.getString(3));
mobileDevice.setImsi(resultSet.getString(4));
mobileDevice.setOsVersion(resultSet.getString(5));
mobileDevice.setModel(resultSet.getString(6));
mobileDevice.setVendor(resultSet.getString(7));
break;
}
} catch (SQLException e) {
String msg = "Error occurred while fetching mobile device '" +
deviceId + "'";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return mobileDevice;
}
@Override
public void addDevice(MobileDevice mobileDevice)
public boolean addDevice(MobileDevice mobileDevice)
throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String createDBQuery =
"INSERT INTO MBL_DEVICE(MOBILE_DEVICE_ID, REG_ID, IMEI, IMSI, OS_VERSION," +
"DEVICE_MODEL, VENDOR) VALUES (?, ?, ?, ?, ?, ?, ?)";
stmt = conn.prepareStatement(createDBQuery);
stmt.setString(1, mobileDevice.getMobileDeviceId());
stmt.setString(2, mobileDevice.getRegId());
stmt.setString(3, mobileDevice.getImei());
stmt.setString(4, mobileDevice.getImsi());
stmt.setString(5, mobileDevice.getOsVersion());
stmt.setString(6, mobileDevice.getModel());
stmt.setString(7, mobileDevice.getVendor());
int rows = stmt.executeUpdate();
if(rows>0){
status = true;
}
} catch (SQLException e) {
String msg = "Error occurred while enrolling mobile device '" +
mobileDevice.getMobileDeviceId() + "'";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return status;
}
@Override
public void updateDevice(MobileDevice mobileDevice)
public boolean updateDevice(MobileDevice mobileDevice)
throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String updateDBQuery =
"UPDATE MBL_DEVICE SET REG_ID = ?, IMEI = ?, IMSI = ?, OS_VERSION = ?," +
"DEVICE_MODEL = ?, VENDOR = ? WHERE MOBILE_DEVICE_ID = ?";
stmt = conn.prepareStatement(updateDBQuery);
stmt.setString(1, mobileDevice.getRegId());
stmt.setString(2, mobileDevice.getImei());
stmt.setString(3, mobileDevice.getImsi());
stmt.setString(4, mobileDevice.getOsVersion());
stmt.setString(5, mobileDevice.getModel());
stmt.setString(6, mobileDevice.getVendor());
stmt.setString(7, mobileDevice.getMobileDeviceId());
int rows = stmt.executeUpdate();
if(rows>0){
status = true;
}
} catch (SQLException e) {
String msg = "Error occurred while updating the mobile device '" +
mobileDevice.getMobileDeviceId() + "'";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return status;
}
@Override
public void deleteDevice(String deviceId) throws MobileDeviceManagementDAOException {
public boolean deleteDevice(String deviceId) throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String deleteDBQuery =
"DELETE FROM MBL_DEVICE WHERE MOBILE_DEVICE_ID = ?";
stmt = conn.prepareStatement(deleteDBQuery);
stmt.setString(1,deviceId);
int rows = stmt.executeUpdate();
if(rows>0){
status = true;
}
} catch (SQLException e) {
String msg = "Error occurred while deleting mobile device " + deviceId;
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return status;
}
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);
}
}
}

@ -1,62 +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 org.wso2.carbon.device.mgt.mobile.impl.dao.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceModelDAO;
import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileDeviceModel;
import javax.sql.DataSource;
/**
* Implementation of MobileDeviceModel.
*/
public class MobileDeviceModelDAOImpl implements MobileDeviceModelDAO {
private DataSource dataSource;
private static final Log log = LogFactory.getLog(MobileDeviceModelDAOImpl.class);
public MobileDeviceModelDAOImpl(DataSource dataSource) {
this.dataSource = dataSource;
}
@Override
public MobileDeviceModel getDeviceModel(String modelId)
throws MobileDeviceManagementDAOException {
return null;
}
@Override
public void addDeviceModel(MobileDeviceModel deviceModel)
throws MobileDeviceManagementDAOException {
}
@Override
public void updateDeviceModel(MobileDeviceModel deviceModel)
throws MobileDeviceManagementDAOException {
}
@Override
public void deleteDeviceModel(String modelId)
throws MobileDeviceManagementDAOException {
}
}

@ -1,62 +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 org.wso2.carbon.device.mgt.mobile.impl.dao.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceVendorDAO;
import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileDeviceVendor;
import javax.sql.DataSource;
/**
* Implementation of MobileDeviceVendorDAO.
*/
public class MobileDeviceVendorDAOImpl implements MobileDeviceVendorDAO {
private DataSource dataSource;
private static final Log log = LogFactory.getLog(MobileDeviceVendorDAOImpl.class);
public MobileDeviceVendorDAOImpl(DataSource dataSource) {
this.dataSource = dataSource;
}
@Override
public MobileDeviceVendor getDeviceModel(String vendorId)
throws MobileDeviceManagementDAOException {
return null;
}
@Override
public void addDeviceVendor(MobileDeviceVendor deviceVendor)
throws MobileDeviceManagementDAOException {
}
@Override
public void updateDeviceVendor(MobileDeviceVendor deviceVendor)
throws MobileDeviceManagementDAOException {
}
@Override
public void deleteDeviceVendor(String vendorId)
throws MobileDeviceManagementDAOException {
}
}

@ -1,58 +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 org.wso2.carbon.device.mgt.mobile.impl.dao.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileOSVersionDAO;
import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileOSVersion;
import javax.sql.DataSource;
/**
* Implementation of MobileOSVersionDAO.
*/
public class MobileOSVersionDAOImpl implements MobileOSVersionDAO {
private DataSource dataSource;
private static final Log log = LogFactory.getLog(MobileOSVersionDAOImpl.class);
public MobileOSVersionDAOImpl(DataSource dataSource) {
this.dataSource = dataSource;
}
@Override public MobileOSVersion getMobileOSVersion(String versionId)
throws MobileDeviceManagementDAOException {
return null;
}
@Override public void addMobileOSVersion(MobileOSVersion osVersion)
throws MobileDeviceManagementDAOException {
}
@Override public void updateMobileOSVersion(MobileOSVersion osVersion)
throws MobileDeviceManagementDAOException {
}
@Override public void deleteMobileOSVersion(String versionId)
throws MobileDeviceManagementDAOException {
}
}

@ -16,14 +16,12 @@
package org.wso2.carbon.device.mgt.mobile.impl.dao.util;
import javax.sql.DataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileDevice;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.mobile.impl.config.datasource.JNDILookupDefinition;
import org.wso2.carbon.device.mgt.mobile.impl.config.datasource.MobileDataSourceConfig;
import org.wso2.carbon.device.mgt.mobile.impl.util.MobileDeviceManagementSchemaInitializer;
import javax.naming.InitialContext;
import javax.sql.DataSource;
@ -32,18 +30,79 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Hashtable;
import java.util.List;
/**
* Utility method required by MobileDeviceManagement DAO classes.
*/
public class MobileDeviceManagementDAOUtil {
public static DataSource resolveDataSource() {
return null;
}
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) {
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());
}
try {
dataSource = MobileDeviceManagementDAOUtil.lookupDataSource(
jndiConfig.getJndiName(), jndiProperties);
} catch (DeviceManagementException e) {
if (log.isDebugEnabled()) {
log.debug("Error in looking up data source: " + e.getMessage());
}
log.error(e);
}
} else {
try {
dataSource = MobileDeviceManagementDAOUtil.lookupDataSource(
jndiConfig.getJndiName(), null);
} catch (DeviceManagementException e) {
if (log.isDebugEnabled()) {
log.debug("Error in looking up data source: " + e.getMessage());
}
log.error(e);
}
}
}
return dataSource;
}
public static DataSource lookupDataSource(String dataSourceName,
final Hashtable<Object, Object> jndiProperties)
throws DeviceManagementException {
try {
if (jndiProperties == null || jndiProperties.isEmpty()) {
return (DataSource) InitialContext.doLookup(dataSourceName);
}
final InitialContext context = new InitialContext(jndiProperties);
return (DataSource) context.doLookup(dataSourceName);
} catch (Exception e) {
throw new DeviceManagementException(
"Error in looking up data source: " + e.getMessage(), e);
}
}
public static void cleanupResources(Connection conn, PreparedStatement stmt, ResultSet rs) {
if (rs != null) {
try {
@ -68,23 +127,46 @@ public class MobileDeviceManagementDAOUtil {
}
}
public static DataSource lookupDataSource(String dataSourceName,
final Hashtable<Object, Object> jndiProperties) {
try {
if (jndiProperties == null || jndiProperties.isEmpty()) {
return (DataSource) InitialContext.doLookup(dataSourceName);
/**
* 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);
}
final InitialContext context = new InitialContext(jndiProperties);
return (DataSource) context.doLookup(dataSourceName);
} catch (Exception e) {
throw new RuntimeException("Error in looking up data source: " + e.getMessage(), e);
}
}
public static MobileDevice convertToMobileDevice(Device device)
throws MobileDeviceManagementDAOException {
MobileDevice mobileDeviceBO = new MobileDevice();
return mobileDeviceBO;
/**
* Creates the mobile device management schema
*
* @param dataSource Mobile data source
*/
public static void setupMobileDeviceManagementSchema(DataSource dataSource) throws
DeviceManagementException {
MobileDeviceManagementSchemaInitializer initializer =
new MobileDeviceManagementSchemaInitializer(dataSource);
log.info("Initializing mobile device management repository database schema");
try {
initializer.createRegistryDatabase();
} catch (Exception e) {
throw new DeviceManagementException(
"Error occurred while initializing Mobile Device Management " +
"database schema", e);
}
}
}

@ -27,9 +27,9 @@ public class MobileDevice implements Serializable {
private String regId;
private String imei;
private String imsi;
private int osVersionId;
private int modelId;
private int vendorId;
private String osVersion;
private String model;
private String vendor;
public String getMobileDeviceId() {
return mobileDeviceId;
@ -63,27 +63,27 @@ public class MobileDevice implements Serializable {
this.imsi = imsi;
}
public int getOsVersionId() {
return osVersionId;
public String getOsVersion() {
return osVersion;
}
public void setOsVersionId(int osVersionId) {
this.osVersionId = osVersionId;
public void setOsVersion(String osVersion) {
this.osVersion = osVersion;
}
public int getModelId() {
return modelId;
public String getModel() {
return model;
}
public void setModelId(int modelId) {
this.modelId = modelId;
public void setModel(String model) {
this.model = model;
}
public int getVendorId() {
return vendorId;
public String getVendor() {
return vendor;
}
public void setVendorId(int vendorId) {
this.vendorId = vendorId;
public void setVendor(String vendor) {
this.vendor = vendor;
}
}

@ -1,44 +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 org.wso2.carbon.device.mgt.mobile.impl.dto;
import java.io.Serializable;
/**
* DTO of MobileDeviceModel.
*/
public class MobileDeviceModel implements Serializable {
private int modelId;
private String model;
public int getModelId() {
return modelId;
}
public void setModelId(int modelId) {
this.modelId = modelId;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
}

@ -1,44 +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 org.wso2.carbon.device.mgt.mobile.impl.dto;
import java.io.Serializable;
/**
* DTO of MobileVendor.
*/
public class MobileDeviceVendor implements Serializable {
private int vendorId;
private String vendor;
public int getVendorId() {
return vendorId;
}
public void setVendorId(int vendorId) {
this.vendorId = vendorId;
}
public String getVendor() {
return vendor;
}
public void setVendor(String vendor) {
this.vendor = vendor;
}
}

@ -1,44 +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 org.wso2.carbon.device.mgt.mobile.impl.dto;
import java.io.Serializable;
/**
* DTO of MobileOSVersion.
*/
public class MobileOSVersion implements Serializable {
private int osVersionId;
private String osVersion;
public int getOsVersionId() {
return osVersionId;
}
public void setOsVersionId(int osVersionId) {
this.osVersionId = osVersionId;
}
public String getOsVersion() {
return osVersion;
}
public void setOsVersion(String osVersion) {
this.osVersion = osVersion;
}
}

@ -19,14 +19,20 @@ package org.wso2.carbon.device.mgt.mobile.impl.internal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.framework.*;
import org.wso2.carbon.apimgt.api.APIManagementException;
import org.wso2.carbon.apimgt.api.APIProvider;
import org.wso2.carbon.apimgt.impl.APIManagerFactory;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService;
import org.wso2.carbon.device.mgt.mobile.impl.DataSourceListener;
import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidDeviceManagerService;
import org.wso2.carbon.device.mgt.mobile.impl.config.APIConfig;
import org.wso2.carbon.device.mgt.mobile.impl.config.MobileDeviceConfigurationManager;
import org.wso2.carbon.device.mgt.mobile.impl.config.MobileDeviceManagementConfig;
import org.wso2.carbon.device.mgt.mobile.impl.config.datasource.MobileDataSourceConfig;
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceDAOFactory;
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.mobile.impl.ios.IOSDeviceManagerService;
import org.wso2.carbon.device.mgt.mobile.impl.util.MobileDeviceManagementSchemaInitializer;
import org.wso2.carbon.device.mgt.mobile.impl.util.DeviceManagementAPIPublisherUtil;
import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManagerService;
import java.util.ArrayList;
@ -37,10 +43,11 @@ public class MobileDeviceManagementBundleActivator implements BundleActivator, B
private ServiceRegistration androidServiceRegRef;
private ServiceRegistration iOSServiceRegRef;
private ServiceRegistration windowsServiceRegRef;
private static List<DataSourceListener> dataSourceListeners = new ArrayList<DataSourceListener>();
private static final String SYMBOLIC_NAME_DATA_SOURCE_COMPONENT = "org.eclipse.osgi";
private static final Log log = LogFactory.getLog(MobileDeviceManagementBundleActivator.class);
private static final String SYMBOLIC_NAME_DATA_SOURCE_COMPONENT = "org.wso2.carbon.ndatasource.core";
@Override
public void start(BundleContext bundleContext) throws Exception {
@ -50,19 +57,14 @@ public class MobileDeviceManagementBundleActivator implements BundleActivator, B
}
bundleContext.addBundleListener(this);
/* If -Dsetup option enabled then create device management database schema */
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");
}
setupMobileDeviceManagementSchema(null);
}
/* Initialize the datasource configuration */
MobileDeviceConfigurationManager.getInstance().initConfig();
MobileDeviceManagementConfig config = MobileDeviceConfigurationManager.getInstance()
.getMobileDeviceManagementConfig();
MobileDataSourceConfig dsConfig =
config.getMobileDeviceMgtRepository().getMobileDataSourceConfig();
MobileDeviceDAOFactory daoFactory = new MobileDeviceDAOFactory();
//TODO Register this dao to an appropriate config file
MobileDeviceManagementDAOFactory.setMobileDataSourceConfig(dsConfig);
androidServiceRegRef =
bundleContext.registerService(DeviceManagerService.class.getName(),
@ -73,11 +75,17 @@ public class MobileDeviceManagementBundleActivator implements BundleActivator, B
windowsServiceRegRef =
bundleContext.registerService(DeviceManagerService.class.getName(),
new WindowsDeviceManagerService(), null);
/* Initialize all API configurations with corresponding API Providers */
this.initAPIConfigs();
/* Publish all mobile device management related JAX-RS services as APIs */
this.publishAPIs();
if (log.isDebugEnabled()) {
log.debug("Mobile Device Management Service bundle is activated");
}
} catch (Throwable e) {
log.error("Error occurred while activating Mobile Device Management Service Component", e);
log.error("Error occurred while activating Mobile Device Management bundle", e);
}
}
@ -86,18 +94,28 @@ public class MobileDeviceManagementBundleActivator implements BundleActivator, B
if (log.isDebugEnabled()) {
log.debug("Deactivating Mobile Device Management Service");
}
androidServiceRegRef.unregister();
iOSServiceRegRef.unregister();
windowsServiceRegRef.unregister();
try {
androidServiceRegRef.unregister();
iOSServiceRegRef.unregister();
windowsServiceRegRef.unregister();
bundleContext.removeBundleListener(this);
bundleContext.removeBundleListener(this);
/* Removing all APIs published upon start-up for mobile device management related JAX-RS
services */
this.removeAPIs();
} catch (Throwable e) {
log.error("Error occurred while de-activating Mobile Device Management bundle");
}
}
@Override
public void bundleChanged(BundleEvent bundleEvent) {
int eventType = bundleEvent.getType();
String bundleSymbolicName = bundleEvent.getBundle().getSymbolicName();
if (SYMBOLIC_NAME_DATA_SOURCE_COMPONENT.equals(bundleSymbolicName) && eventType == BundleEvent.STARTED) {
if (SYMBOLIC_NAME_DATA_SOURCE_COMPONENT.equals(bundleSymbolicName) &&
eventType == BundleEvent.STARTED) {
for (DataSourceListener listener : this.getDataSourceListeners()) {
listener.notifyObserver();
}
@ -112,19 +130,37 @@ public class MobileDeviceManagementBundleActivator implements BundleActivator, B
return dataSourceListeners;
}
private void setupMobileDeviceManagementSchema(MobileDataSourceConfig config) throws
DeviceManagementException {
MobileDeviceManagementSchemaInitializer initializer =
new MobileDeviceManagementSchemaInitializer(config);
log.info("Initializing mobile device management repository database schema");
try {
//initializer.createRegistryDatabase();
} catch (Exception e) {
throw new DeviceManagementException(
"Error occurred while initializing Mobile Device Management " +
"database schema", e);
private void initAPIConfigs() throws DeviceManagementException {
List<APIConfig> apiConfigs =
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
getApiPublisherConfig().getApis();
for (APIConfig apiConfig : apiConfigs) {
try {
APIProvider provider = APIManagerFactory.getInstance().getAPIProvider(apiConfig.getOwner());
apiConfig.init(provider);
} catch (APIManagementException e) {
throw new DeviceManagementException("Error occurred while initializing API Config '" +
apiConfig.getName() + "'", e);
}
}
}
private void publishAPIs() throws DeviceManagementException {
List<APIConfig> apiConfigs =
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
getApiPublisherConfig().getApis();
for (APIConfig apiConfig : apiConfigs) {
DeviceManagementAPIPublisherUtil.publishAPI(apiConfig);
}
}
private void removeAPIs() throws DeviceManagementException {
List<APIConfig> apiConfigs =
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
getApiPublisherConfig().getApis();
for (APIConfig apiConfig : apiConfigs) {
DeviceManagementAPIPublisherUtil.removeAPI(apiConfig);
}
}
}

@ -0,0 +1,111 @@
/**
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wso2.carbon.device.mgt.mobile.impl.util;
import org.wso2.carbon.apimgt.api.APIManagementException;
import org.wso2.carbon.apimgt.api.APIProvider;
import org.wso2.carbon.apimgt.api.model.API;
import org.wso2.carbon.apimgt.api.model.APIIdentifier;
import org.wso2.carbon.apimgt.api.model.APIStatus;
import org.wso2.carbon.apimgt.api.model.URITemplate;
import org.wso2.carbon.apimgt.impl.APIConstants;
import org.wso2.carbon.apimgt.usage.publisher.service.APIMGTConfigReaderService;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.mobile.impl.config.APIConfig;
import org.wso2.carbon.utils.CarbonUtils;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
public class DeviceManagementAPIPublisherUtil {
enum HTTPMethod {
GET, POST, DELETE, PUT, OPTIONS
}
private static List<HTTPMethod> httpMethods;
static {
httpMethods = new ArrayList<HTTPMethod>();
httpMethods.add(HTTPMethod.GET);
httpMethods.add(HTTPMethod.POST);
httpMethods.add(HTTPMethod.DELETE);
httpMethods.add(HTTPMethod.PUT);
httpMethods.add(HTTPMethod.OPTIONS);
}
public static void publishAPI(APIConfig config) throws DeviceManagementException {
APIProvider provider = config.getProvider();
APIIdentifier id = new APIIdentifier(config.getOwner(), config.getName(), config.getVersion());
API api = new API(id);
try {
api.setContext(config.getContext());
api.setUrl(config.getVersion());
api.setUriTemplates(getURITemplates(config.getEndpoint(),
APIConstants.AUTH_APPLICATION_OR_USER_LEVEL_TOKEN));
api.setVisibility(APIConstants.API_GLOBAL_VISIBILITY);
api.addAvailableTiers(provider.getTiers());
api.setEndpointSecured(false);
api.setStatus(APIStatus.PUBLISHED);
api.setTransports(config.getTransports());
provider.addAPI(api);
} catch (APIManagementException e) {
throw new DeviceManagementException("Error occurred while registering the API", e);
}
}
public static void removeAPI(APIConfig config) throws DeviceManagementException {
try {
APIProvider provider = config.getProvider();
APIIdentifier id = new APIIdentifier(config.getOwner(), config.getName(), config.getVersion());
provider.deleteAPI(id);
} catch (APIManagementException e) {
throw new DeviceManagementException("Error occurred while removing API", e);
}
}
private static Set<URITemplate> getURITemplates(String endpoint, String authType) {
Set<URITemplate> uriTemplates = new LinkedHashSet<URITemplate>();
if (APIConstants.AUTH_NO_AUTHENTICATION.equals(authType)) {
for (HTTPMethod method : httpMethods) {
URITemplate template = new URITemplate();
template.setAuthType(APIConstants.AUTH_NO_AUTHENTICATION);
template.setHTTPVerb(method.toString());
template.setResourceURI(endpoint);
template.setUriTemplate("/*");
uriTemplates.add(template);
}
} else {
for (HTTPMethod method : httpMethods) {
URITemplate template = new URITemplate();
if (HTTPMethod.OPTIONS.equals(method)) {
template.setAuthType(APIConstants.AUTH_NO_AUTHENTICATION);
} else {
template.setAuthType(APIConstants.AUTH_APPLICATION_OR_USER_LEVEL_TOKEN);
}
template.setHTTPVerb(method.toString());
template.setResourceURI(endpoint);
template.setUriTemplate("/*");
uriTemplates.add(template);
}
}
return uriTemplates;
}
}

@ -31,12 +31,9 @@ import java.io.File;
import java.util.Hashtable;
import java.util.List;
/**
* Created by harshan on 12/15/14.
*/
public class MobileDeviceManagerUtil {
public class DeviceManagementUtil {
private static final Log log = LogFactory.getLog(MobileDeviceManagerUtil.class);
private static final Log log = LogFactory.getLog(DeviceManagementUtil.class);
public static Document convertToDocument(File file) throws DeviceManagementException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
@ -51,41 +48,4 @@ public class MobileDeviceManagerUtil {
}
}
/**
* Resolve data source from the data source definition
*
* @param config data source configuration
* @return data source resolved from the data source definition
*/
public static DataSource resolveDataSource(MobileDataSourceConfig config) {
DataSource dataSource = null;
if (config == null) {
throw new RuntimeException(
"Mobile 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 Mobile 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;
}
}

@ -18,10 +18,10 @@ package org.wso2.carbon.device.mgt.mobile.impl.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.mobile.impl.config.datasource.MobileDataSourceConfig;
import org.wso2.carbon.utils.CarbonUtils;
import org.wso2.carbon.utils.dbcreator.DatabaseCreator;
import javax.sql.DataSource;
import java.io.File;
public final class MobileDeviceManagementSchemaInitializer extends DatabaseCreator {
@ -29,10 +29,10 @@ public final class MobileDeviceManagementSchemaInitializer extends DatabaseCreat
private static final Log log = LogFactory.getLog(MobileDeviceManagementSchemaInitializer.class);
private static final String setupSQLScriptBaseLocation =
CarbonUtils.getCarbonHome() + File.separator + "dbscripts" + File.separator + "cdm" +
File.separator + "plugins";
File.separator + "plugins" + File.separator ;
public MobileDeviceManagementSchemaInitializer(MobileDataSourceConfig config) {
super(MobileDeviceManagerUtil.resolveDataSource(config));
public MobileDeviceManagementSchemaInitializer(DataSource dataSource) {
super(dataSource);
}
protected String getDbScriptLocation(String databaseType) {

@ -0,0 +1,109 @@
/*
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wso2.carbon.device.mgt.mobile.impl.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileDevice;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
/**
* Provides utility methods required by the mobile device management bundle.
*/
public class MobileDeviceManagementUtil {
private static final Log log = LogFactory.getLog(MobileDeviceManagementUtil.class);
private static final String MOBILE_DEVICE_IMEI = "imei";
private static final String MOBILE_DEVICE_IMSI = "imsi";
private static final String MOBILE_DEVICE_REG_ID = "regId";
private static final String MOBILE_DEVICE_VENDOR = "vendor";
private static final String MOBILE_DEVICE_OS_VERSION = "osVersion";
private static final String MOBILE_DEVICE_MODEL = "model";
public static Document convertToDocument(File file) throws DeviceManagementException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
try {
DocumentBuilder docBuilder = factory.newDocumentBuilder();
return docBuilder.parse(file);
} catch (Exception e) {
throw new DeviceManagementException(
"Error occurred while parsing file, while converting " +
"to a org.w3c.dom.Document : " + e.getMessage(), e);
}
}
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) {
MobileDevice mobileDevice = null;
if (device != null) {
mobileDevice = new MobileDevice();
mobileDevice.setMobileDeviceId(device.getDeviceIdentifier());
mobileDevice.setImei(getPropertyValue(device, MOBILE_DEVICE_IMEI));
mobileDevice.setImsi(getPropertyValue(device, MOBILE_DEVICE_IMSI));
mobileDevice.setRegId(getPropertyValue(device, MOBILE_DEVICE_REG_ID));
mobileDevice.setModel(getPropertyValue(device, MOBILE_DEVICE_MODEL));
mobileDevice.setOsVersion(getPropertyValue(device, MOBILE_DEVICE_OS_VERSION));
mobileDevice.setVendor(getPropertyValue(device, MOBILE_DEVICE_VENDOR));
}
return mobileDevice;
}
public static Device convertToDevice(MobileDevice mobileDevice) {
Device device = null;
if(mobileDevice!=null){
device = new Device();
List<Device.Property> propertyList = new ArrayList<Device.Property>();
propertyList.add(getProperty(MOBILE_DEVICE_IMEI,mobileDevice.getImei()));
propertyList.add(getProperty(MOBILE_DEVICE_IMSI,mobileDevice.getImsi()));
propertyList.add(getProperty(MOBILE_DEVICE_REG_ID,mobileDevice.getRegId()));
propertyList.add(getProperty(MOBILE_DEVICE_MODEL,mobileDevice.getModel()));
propertyList.add(getProperty(MOBILE_DEVICE_OS_VERSION,mobileDevice.getOsVersion()));
propertyList.add(getProperty(MOBILE_DEVICE_VENDOR,mobileDevice.getVendor()));
device.setProperties(propertyList);
device.setDeviceIdentifier(mobileDevice.getMobileDeviceId());
}
return device;
}
}

@ -40,6 +40,7 @@
<module>org.wso2.carbon.device.mgt.core</module>
<module>org.wso2.carbon.device.mgt.common</module>
<module>org.wso2.carbon.device.mgt.mobile.impl</module>
<module>org.wso2.carbon.device.mgt.oauth.token.handler</module>
</modules>
<dependencyManagement>
@ -74,6 +75,26 @@
<artifactId>h2-database-engine</artifactId>
<version>${orbit.version.h2.engine}</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>
@ -98,5 +119,7 @@
</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>

@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" 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">
<parent>
<groupId>org.wso2.carbon</groupId>
<artifactId>key-mgt</artifactId>
<version>2.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.key.mgt.handler.valve</artifactId>
<version>2.0.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Key Management Handler Valve</name>
<description>WSO2 Carbon - Key Management Handler Valve</description>
<url>http://wso2.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Require-Bundle>org.wso2.carbon.tomcat.patch</Require-Bundle>
<Private-Package>
org.wso2.carbon.key.mgt.handler.valve.*
</Private-Package>
<Fragment-Host>tomcat</Fragment-Host>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.tomcat.wso2</groupId>
<artifactId>tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.apimgt.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.apimgt.impl</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.tomcat.ext</artifactId>
</dependency>
</dependencies>
</project>

@ -0,0 +1,37 @@
/**
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wso2.carbon.key.mgt.handler.valve;
public class APIFaultException extends Exception {
private static final long serialVersionUID = 1L;
private int errorCode;
public APIFaultException(int errorCode, String message) {
super(message);
this.errorCode = errorCode;
}
public APIFaultException(int errorCode, String message, Throwable cause) {
super(message, cause);
this.errorCode = errorCode;
}
public int getErrorCode() {
return errorCode;
}
}

@ -0,0 +1,25 @@
/**
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wso2.carbon.key.mgt.handler.valve;
public class HandlerConstants {
public static final String HEADER_AUTHORIZATION = "Authorization";
public static final String TOKEN_NAME_BEARER = "Bearer";
public static final String NO_MATCHING_AUTH_SCHEME = "noMatchedAuthScheme";
}

@ -0,0 +1,138 @@
/**
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wso2.carbon.key.mgt.handler.valve;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.catalina.connector.Response;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.apimgt.api.APIManagementException;
import org.wso2.carbon.apimgt.core.APIManagerErrorConstants;
import org.wso2.carbon.apimgt.core.authenticate.APITokenValidator;
import org.wso2.carbon.apimgt.impl.APIConstants;
import org.wso2.carbon.apimgt.impl.dto.APIKeyValidationInfoDTO;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.identity.base.IdentityException;
import org.wso2.carbon.identity.core.util.IdentityUtil;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
public class HandlerUtil {
private static APIKeyValidationInfoDTO apiKeyValidationDTO;
private static final Log log = LogFactory.getLog(HandlerUtil.class);
/**
* Retrieve bearer token form the HTTP header
* @param bearerToken Bearer Token extracted out of the corresponding HTTP header
*/
public static String getAccessToken(String bearerToken) {
String accessToken = null;
String[] token = bearerToken.split(HandlerConstants.TOKEN_NAME_BEARER);
if (token.length > 1 && token[1] != null) {
accessToken = token[1].trim();
}
return accessToken;
}
public static String getAPIVersion(HttpServletRequest request) {
int contextStartsIndex = (request.getRequestURI()).indexOf(request.getContextPath()) + 1;
int length = request.getContextPath().length();
String afterContext = (request.getRequestURI()).substring(contextStartsIndex + length);
int SlashIndex = afterContext.indexOf(("/"));
if (SlashIndex != -1) {
return afterContext.substring(0, SlashIndex);
} else {
return afterContext;
}
}
public static void handleNoMatchAuthSchemeCallForRestService(Response response,String httpVerb, String reqUri,
String version, String context ) {
String errMsg = "Resource is not matched for HTTP Verb " + httpVerb + ". API context " + context +
",version " + version + ", request " + reqUri;
APIFaultException e = new APIFaultException( APIManagerErrorConstants.API_AUTH_INCORRECT_API_RESOURCE, errMsg);
String faultPayload = getFaultPayload(e, APIManagerErrorConstants.API_SECURITY_NS,
APIManagerErrorConstants.API_SECURITY_NS_PREFIX).toString();
handleRestFailure(response, faultPayload);
}
public static boolean doAuthenticate(String context, String version, String accessToken,
String requiredAuthenticationLevel, String clientDomain)
throws APIManagementException,
APIFaultException {
if (APIConstants.AUTH_NO_AUTHENTICATION.equals(requiredAuthenticationLevel)) {
return true;
}
APITokenValidator tokenValidator = new APITokenValidator();
apiKeyValidationDTO = tokenValidator.validateKey(context, version, accessToken,
requiredAuthenticationLevel, clientDomain);
if (apiKeyValidationDTO.isAuthorized()) {
String userName = apiKeyValidationDTO.getEndUserName();
PrivilegedCarbonContext.getThreadLocalCarbonContext()
.setUsername(apiKeyValidationDTO.getEndUserName());
try {
PrivilegedCarbonContext.getThreadLocalCarbonContext()
.setTenantId(IdentityUtil.getTenantIdOFUser(userName));
} catch (IdentityException e) {
log.error("Error while retrieving Tenant Id", e);
return false;
}
return true;
} else {
throw new APIFaultException(apiKeyValidationDTO.getValidationStatus(),
"Access failure for API: " + context + ", version: " +
version + " with key: " + accessToken);
}
}
public static void handleRestFailure(Response response, String payload) {
response.setStatus(403);
response.setContentType("application/xml");
response.setCharacterEncoding("UTF-8");
try {
response.getWriter().write(payload);
} catch (IOException e) {
log.error("Error in sending fault response", e);
}
}
public static OMElement getFaultPayload(APIFaultException exception, String FaultNS,
String FaultNSPrefix) {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace ns = fac.createOMNamespace(FaultNS, FaultNSPrefix);
OMElement payload = fac.createOMElement("fault", ns);
OMElement errorCode = fac.createOMElement("code", ns);
errorCode.setText(String.valueOf(exception.getErrorCode()));
OMElement errorMessage = fac.createOMElement("message", ns);
errorMessage.setText(APIManagerErrorConstants.getFailureMessage(exception.getErrorCode()));
OMElement errorDetail = fac.createOMElement("description", ns);
errorDetail.setText(exception.getMessage());
payload.addChild(errorCode);
payload.addChild(errorMessage);
payload.addChild(errorDetail);
return payload;
}
}

@ -0,0 +1,141 @@
/**
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wso2.carbon.key.mgt.handler.valve;
import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response;
import org.apache.catalina.valves.ValveBase;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.apimgt.api.APIManagementException;
import org.wso2.carbon.apimgt.core.authenticate.APITokenValidator;
import org.wso2.carbon.apimgt.core.gateway.APITokenAuthenticator;
import org.wso2.carbon.apimgt.impl.APIConstants;
import org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO;
import org.wso2.carbon.apimgt.impl.utils.APIUtil;
import javax.servlet.ServletException;
import java.io.IOException;
import java.util.Enumeration;
public class OAuthTokenValidatorValve extends ValveBase {
private static final Log log = LogFactory.getLog(OAuthTokenValidatorValve.class);
APITokenAuthenticator authenticator;
public OAuthTokenValidatorValve() {
authenticator = new APITokenAuthenticator();
}
@Override
public void invoke(Request request, Response response) throws java.io.IOException, javax.servlet.ServletException {
String context = request.getContextPath();
if (context == null || context.equals("")) {
//Invoke the next valve in handler chain.
getNext().invoke(request, response);
return;
}
boolean contextExist;
Boolean contextValueInCache = null;
if (APIUtil.getAPIContextCache().get(context) != null) {
contextValueInCache = Boolean.parseBoolean(APIUtil.getAPIContextCache().get(context).toString());
}
if (contextValueInCache != null) {
contextExist = contextValueInCache;
} else {
contextExist = ApiMgtDAO.isContextExist(context);
APIUtil.getAPIContextCache().put(context, contextExist);
}
if (!contextExist) {
getNext().invoke(request, response);
return;
}
try {
handleWSDLGetRequest(request, response, context);
} catch (IOException e) {
e.printStackTrace();
} catch (ServletException e) {
e.printStackTrace();
}
String authHeader = request.getHeader(APIConstants.OperationParameter.AUTH_PARAM_NAME);
String accessToken = null;
/* Authenticate*/
try {
if (authHeader != null) {
accessToken = HandlerUtil.getAccessToken(authHeader);
} else {
// There can be some API published with None Auth Type
/*
* throw new
* APIFaultException(APIConstants.KeyValidationStatus
* .API_AUTH_INVALID_CREDENTIALS,
* "Invalid format for Authorization header. Expected 'Bearer <token>'"
* );
*/
}
String apiVersion = HandlerUtil.getAPIVersion(request);
String domain = request.getHeader(APITokenValidator.getAPIManagerClientDomainHeader());
String authLevel = authenticator.getResourceAuthenticationScheme(context,
apiVersion,
request.getRequestURI(),
request.getMethod());
if (HandlerConstants.NO_MATCHING_AUTH_SCHEME.equals(authLevel)) {
HandlerUtil.handleNoMatchAuthSchemeCallForRestService(response,
request.getMethod(), request.getRequestURI(),
apiVersion, context);
return;
} else {
HandlerUtil.doAuthenticate(context, apiVersion, accessToken, authLevel, domain);
}
} catch (APIManagementException e) {
//ignore
} catch (APIFaultException e) {
log.error("Error occurred while key validation", e);
return;
}
getNext().invoke(request, response);
}
private void handleWSDLGetRequest(Request request, Response response,
String context) throws IOException, ServletException {
if (request.getMethod().equals("GET")) {
// TODO:Need to get these paths from a config file.
if (request.getRequestURI().matches(context + "/[^/]*/services")) {
getNext().invoke(request, response);
return;
}
Enumeration<String> params = request.getParameterNames();
String paramName;
while (params.hasMoreElements()) {
paramName = params.nextElement();
if (paramName.endsWith("wsdl") || paramName.endsWith("wadl")) {
getNext().invoke(request, response);
return;
}
}
}
}
}

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
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">
<parent>
<groupId>org.wso2.carbon</groupId>
<artifactId>wso2cdm-parent</artifactId>
<version>2.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon</groupId>
<artifactId>key-mgt</artifactId>
<version>2.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>WSO2 Carbon - Device Management Component</name>
<url>http://wso2.org</url>
<modules>
<module>org.wso2.carbon.key.mgt.handler.valve</module>
</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>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
<version>1.7.2</version>
<executions>
<execution>
<id>generate-scr-scrdescriptor</id>
<goals>
<goal>scr</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</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>

@ -24,6 +24,15 @@ public class Policy {
private int id;
private String policyName;
private List<Feature> featuresList;
private boolean generic;
public boolean isGeneric() {
return generic;
}
public void setGeneric(boolean generic) {
this.generic = generic;
}
public int getId() {
return id;

@ -23,4 +23,15 @@
</JndiLookupDefinition>
</DataSourceConfiguration>
</ManagementRepository>
<APIPublisher>
<API>
<Name>enrollment</Name>
<Provider>admin</Provider>
<Context>enrollment</Context>
<Version>1.0.0</Version>
<Endpoint>http://localhost:9763/</Endpoint>
<Transports>http,https</Transports>
</API>
</APIPublisher>
</MobileDeviceMgtConfiguration>

@ -169,7 +169,7 @@
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
<version>1.1.1</version>
<version>1.9.0</version>
</dependency>
</dependencies>
<properties>

@ -18,8 +18,6 @@ package cdm.api.android;
import javax.ws.rs.*;
@Produces({ "application/json", "application/xml" })
@Consumes({ "application/json", "application/xml" })
@Path("/authenticate/")
public class Authentication {
@ -27,16 +25,13 @@ public class Authentication {
@Path("/device/")
public String authenticateDevice(@FormParam("username") String username,
@FormParam("password") String password) {
/* JsonObject result = new JsonObject();
result.addProperty("senderId", "jwwfowrjwqporqwrpqworpq");*/
return "";
return "jwwfowrjwqporqwrpqworpq";
}
@POST
@Path("/device/license")
@Produces ("text/plain")
public String getLicense() {
/* JsonObject result = new JsonObject();
result.addProperty("licenseText", "License Agreement");*/
return "";
return "License Agreement";
}
}

@ -30,7 +30,6 @@ import org.wso2.carbon.device.mgt.core.service.DeviceManagementService;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.List;
/**
@ -40,106 +39,107 @@ import java.util.List;
@Consumes({ "application/json", "application/xml" })
public class Device {
private static Log log = LogFactory.getLog(Device.class);
@GET
public List<org.wso2.carbon.device.mgt.common.Device> getAllDevices() {
List<org.wso2.carbon.device.mgt.common.Device> devices = null;
String msg = "";
DeviceManagementService dmService;
try {
dmService = AndroidAPIUtils.getDeviceManagementService();
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
try {
if (dmService != null) {
devices = dmService.getAllDevices(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
Response.status(HttpStatus.SC_OK);
} else {
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
}
} catch (DeviceManagementException e) {
msg = "Error occurred while fetching the device list";
log.error(msg, e);
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
}
return devices;
}
@GET
@Path("{id}")
public org.wso2.carbon.device.mgt.common.Device getDevice(@PathParam("id") String id) {
String msg = "";
DeviceManagementService dmService;
org.wso2.carbon.device.mgt.common.Device device = new org.wso2.carbon.device.mgt.common.Device();
try {
dmService = AndroidAPIUtils.getDeviceManagementService();
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
try {
if (dmService != null) {
device = dmService.getDevice(deviceIdentifier);
if (device == null) {
Response.status(HttpStatus.SC_NOT_FOUND);
}
} else {
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
}
} catch (DeviceManagementException e) {
msg = "Error occurred while fetching the device information";
log.error(msg, e);
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
}
return device;
}
@PUT
@Path("{id}")
public Message updateDevice(@PathParam("id") String id, org.wso2.carbon.device.mgt.common.Device device) {
boolean result = false;
String msg = "";
DeviceManagementService dmService;
Message responseMessage = new Message();
try {
dmService = AndroidAPIUtils.getDeviceManagementService();
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
try {
if (dmService != null) {
result = dmService.updateDeviceInfo(device);
if (result) {
Response.status(HttpStatus.SC_OK);
responseMessage.setResponseMessage("Device has modified");
} else {
Response.status(HttpStatus.SC_NOT_MODIFIED);
responseMessage.setResponseMessage("Update device has failed");
}
} else {
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
msg = AndroidConstants.Messages.DEVICE_MANAGER_SERVICE_NOT_AVAILABLE;
responseMessage.setResponseMessage(msg);
}
} catch (DeviceManagementException e) {
msg = "Error occurred while modifying the device information";
log.error(msg, e);
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
responseMessage.setResponseMessage(msg);
}
return responseMessage;
}
private static Log log = LogFactory.getLog(Device.class);
@GET
public List<org.wso2.carbon.device.mgt.common.Device> getAllDevices() {
List<org.wso2.carbon.device.mgt.common.Device> devices = null;
String msg = "";
DeviceManagementService dmService;
try {
dmService = AndroidAPIUtils.getDeviceManagementService();
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
try {
if (dmService != null) {
devices = dmService.getAllDevices(
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
Response.status(HttpStatus.SC_OK);
} else {
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
}
} catch (DeviceManagementException e) {
msg = "Error occurred while fetching the device list.";
log.error(msg, e);
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
}
return devices;
}
@GET
@Path("{id}")
public org.wso2.carbon.device.mgt.common.Device getDevice(@PathParam("id") String id) {
String msg = "";
DeviceManagementService dmService;
org.wso2.carbon.device.mgt.common.Device device =
new org.wso2.carbon.device.mgt.common.Device();
try {
dmService = AndroidAPIUtils.getDeviceManagementService();
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
try {
if (dmService != null) {
device = dmService.getDevice(deviceIdentifier);
if (device == null) {
Response.status(HttpStatus.SC_NOT_FOUND);
}
} else {
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
}
} catch (DeviceManagementException e) {
msg = "Error occurred while fetching the device information.";
log.error(msg, e);
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
}
return device;
}
@PUT
@Path("{id}")
public Message updateDevice(@PathParam("id") String id,
org.wso2.carbon.device.mgt.common.Device device) {
boolean result = false;
String msg = "";
DeviceManagementService dmService;
Message responseMessage = new Message();
try {
dmService = AndroidAPIUtils.getDeviceManagementService();
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
try {
if (dmService != null) {
device.setType(
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
result = dmService.updateDeviceInfo(device);
if (result) {
Response.status(HttpStatus.SC_OK);
responseMessage.setResponseMessage("Device information has modified successfully.");
} else {
Response.status(HttpStatus.SC_NOT_MODIFIED);
responseMessage.setResponseMessage("Update device has failed.");
}
} else {
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
msg = AndroidConstants.Messages.DEVICE_MANAGER_SERVICE_NOT_AVAILABLE;
responseMessage.setResponseMessage(msg);
}
} catch (DeviceManagementException e) {
msg = "Error occurred while modifying the device information.";
log.error(msg, e);
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
responseMessage.setResponseMessage(msg);
}
return responseMessage;
}
}

@ -25,6 +25,7 @@ import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementService;
@ -38,166 +39,186 @@ import javax.ws.rs.core.Response;
@Consumes({ "application/json", "application/xml" })
public class Enrollment {
private static Log log = LogFactory.getLog(Enrollment.class);
@POST
public Message enrollDevice(Device device) {
boolean result = false;
int status = 0;
String msg = "";
DeviceManagementService dmService;
Message responseMsg = new Message();
try {
dmService = AndroidAPIUtils.getDeviceManagementService();
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
try {
if (dmService != null) {
result = dmService.enrollDevice(device);
Response.status(HttpStatus.SC_CREATED);
responseMsg.setResponseMessage("Device enrollment has succeeded");
return responseMsg;
} else {
responseMsg.setResponseMessage(AndroidConstants.Messages.DEVICE_MANAGER_SERVICE_NOT_AVAILABLE);
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
return responseMsg;
}
} catch (DeviceManagementException e) {
log.error(msg, e);
responseMsg.setResponseMessage("Error occurred while enrolling the device");
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
return responseMsg;
}
}
@GET
@Path("{id}")
public Message isEnrolled(@PathParam("id") String id) {
boolean result = false;
String msg = "";
DeviceManagementService dmService;
Message responseMsg = new Message();
try {
dmService = AndroidAPIUtils.getDeviceManagementService();
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
try {
if (dmService != null) {
result = dmService.isEnrolled(deviceIdentifier);
if (result) {
Response.status(HttpStatus.SC_OK);
responseMsg.setResponseMessage("Device already enroll");
} else {
Response.status(HttpStatus.SC_NOT_FOUND);
responseMsg.setResponseMessage("Device not enroll");
}
return responseMsg;
} else {
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
responseMsg.setResponseMessage(AndroidConstants.Messages.DEVICE_MANAGER_SERVICE_NOT_AVAILABLE);
return responseMsg;
}
} catch (DeviceManagementException e) {
msg = "Error occurred while checking enrollment of the device";
log.error(msg, e);
responseMsg.setResponseMessage(msg);
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
return responseMsg;
}
}
@PUT
@Path("{id}")
public Message modifyEnrollment(@PathParam("id") String id, Device device) {
boolean result = false;
String msg = "";
DeviceManagementService dmService;
Message responseMsg = new Message();
try {
dmService = AndroidAPIUtils.getDeviceManagementService();
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
try {
if (dmService != null) {
result = dmService.modifyEnrollment(device);
if (result) {
responseMsg.setResponseMessage("update device");
Response.status(HttpStatus.SC_OK);
}else{
responseMsg.setResponseMessage("Update enrollment has failed");
Response.status(HttpStatus.SC_NOT_MODIFIED);
}
} else {
msg = AndroidConstants.Messages.DEVICE_MANAGER_SERVICE_NOT_AVAILABLE;
responseMsg.setResponseMessage(msg);
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
}
return responseMsg;
} catch (DeviceManagementException e) {
msg = "Error occurred while modifying enrollment of the device";
log.error(msg, e);
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
responseMsg.setResponseMessage(msg);
return responseMsg;
}
}
@DELETE
@Path("{id}")
public Message disenrollDevice(@PathParam("id") String id) {
boolean result = false;
String msg = "";
DeviceManagementService dmService;
Message responseMsg = new Message();
try {
dmService = AndroidAPIUtils.getDeviceManagementService();
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
try {
if (dmService != null) {
result = dmService.disenrollDevice(deviceIdentifier);
if (result) {
responseMsg.setResponseMessage("Dis enrolled device");
Response.status(HttpStatus.SC_OK);
}else{
responseMsg.setResponseMessage("Device not found");
Response.status(HttpStatus.SC_NOT_FOUND);
}
} else {
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
msg = AndroidConstants.Messages.DEVICE_MANAGER_SERVICE_NOT_AVAILABLE;
responseMsg.setResponseMessage(msg);
}
return responseMsg;
} catch (DeviceManagementException e) {
msg = "Error occurred while disenrolling the device";
log.error(msg, e);
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
responseMsg.setResponseMessage(msg);
return responseMsg;
}
}
private static Log log = LogFactory.getLog(Enrollment.class);
/*
* Request Format : {"deviceIdentifier":"macid","description":"description","ownership":"BYOD",
* "properties":[{"name":"username","value":"harshan"},{"name":"device","value":"Harshan S5"},
* {"name":"imei","value":"356938035643809"},{"name":"imsi","value":"404685505601234"},{"name":"model","value":"Galaxy S5"},
* {"name":"regId","value":"02fab24b2242"},{"name":"vendor","value":"Samsung"},
* {"name":"osVersion","value":"5.0.0"}]}
*
**/
@POST
public Message enrollDevice(Device device) {
boolean result = false;
int status = 0;
String msg = "";
DeviceManagementService dmService;
Message responseMsg = new Message();
try {
dmService = AndroidAPIUtils.getDeviceManagementService();
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
try {
if (dmService != null) {
device.setType(
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
result = dmService.enrollDevice(device);
Response.status(HttpStatus.SC_CREATED);
responseMsg.setResponseMessage("Device enrollment has succeeded");
return responseMsg;
} else {
responseMsg.setResponseMessage(
AndroidConstants.Messages.DEVICE_MANAGER_SERVICE_NOT_AVAILABLE);
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
return responseMsg;
}
} catch (DeviceManagementException e) {
log.error(msg, e);
responseMsg.setResponseMessage("Error occurred while enrolling the device");
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
return responseMsg;
}
}
@GET
@Path("{id}")
public Message isEnrolled(@PathParam("id") String id) {
boolean result = false;
String msg = "";
DeviceManagementService dmService;
Message responseMsg = new Message();
try {
dmService = AndroidAPIUtils.getDeviceManagementService();
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
try {
if (dmService != null) {
result = dmService.isEnrolled(deviceIdentifier);
if (result) {
Response.status(HttpStatus.SC_OK);
responseMsg.setResponseMessage("Device has already enrolled");
} else {
Response.status(HttpStatus.SC_NOT_FOUND);
responseMsg.setResponseMessage("Device has not enrolled");
}
return responseMsg;
} else {
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
responseMsg.setResponseMessage(
AndroidConstants.Messages.DEVICE_MANAGER_SERVICE_NOT_AVAILABLE);
return responseMsg;
}
} catch (DeviceManagementException e) {
msg = "Error occurred while checking the enrollment of the device.";
log.error(msg, e);
responseMsg.setResponseMessage(msg);
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
return responseMsg;
}
}
/*
* Request Format : {"deviceIdentifier":"macid","description":"description","ownership":"BYOD",
* "properties":[{"name":"username","value":"harshan"},{"name":"device","value":"Harshan S5"},
* {"name":"imei","value":"356938035643809"},{"name":"imsi","value":"404685505601234"},{"name":"model","value":"Galaxy S5"},
* {"name":"regId","value":"02fab24b2242"},{"name":"vendor","value":"Samsung"},
* {"name":"osVersion","value":"5.0.0"}]}
*
**/
@PUT
@Path("{id}")
public Message modifyEnrollment(@PathParam("id") String id, Device device) {
boolean result = false;
String msg = "";
DeviceManagementService dmService;
Message responseMsg = new Message();
try {
dmService = AndroidAPIUtils.getDeviceManagementService();
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
try {
if (dmService != null) {
device.setType(
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
result = dmService.modifyEnrollment(device);
if (result) {
responseMsg.setResponseMessage("Device enrollment has updated successfully");
Response.status(HttpStatus.SC_OK);
} else {
responseMsg.setResponseMessage("Update enrollment has failed");
Response.status(HttpStatus.SC_NOT_MODIFIED);
}
} else {
msg = AndroidConstants.Messages.DEVICE_MANAGER_SERVICE_NOT_AVAILABLE;
responseMsg.setResponseMessage(msg);
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
}
return responseMsg;
} catch (DeviceManagementException e) {
msg = "Error occurred while modifying enrollment of the device";
log.error(msg, e);
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
responseMsg.setResponseMessage(msg);
return responseMsg;
}
}
@DELETE
@Path("{id}")
public Message disenrollDevice(@PathParam("id") String id) {
boolean result = false;
String msg = "";
DeviceManagementService dmService;
Message responseMsg = new Message();
try {
dmService = AndroidAPIUtils.getDeviceManagementService();
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
try {
if (dmService != null) {
result = dmService.disenrollDevice(deviceIdentifier);
if (result) {
responseMsg.setResponseMessage("Device has disenrolled successfully");
Response.status(HttpStatus.SC_OK);
} else {
responseMsg.setResponseMessage("Device not found");
Response.status(HttpStatus.SC_NOT_FOUND);
}
} else {
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
msg = AndroidConstants.Messages.DEVICE_MANAGER_SERVICE_NOT_AVAILABLE;
responseMsg.setResponseMessage(msg);
}
return responseMsg;
} catch (DeviceManagementException e) {
msg = "Error occurred while disenrolling the device";
log.error(msg, e);
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
responseMsg.setResponseMessage(msg);
return responseMsg;
}
}
}

@ -1,34 +0,0 @@
package cdm.api.android;
import org.wso2.carbon.device.mgt.common.*;
import org.wso2.carbon.device.mgt.common.Device;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.List;
@Produces({"application/json", "application/xml"})
@Consumes({"application/json", "application/xml"})
public class Test {
@GET
public List<org.wso2.carbon.device.mgt.common.Device> getAllDevices() {
Device dev = new Device();
dev.setName("test1");
dev.setDateOfEnrolment(11111111L);
dev.setDateOfLastUpdate(992093209L);
dev.setDescription("sassasaas");
ArrayList<Device> listdevices = new ArrayList<Device>();
listdevices.add(dev);
return listdevices;
}
}

@ -23,7 +23,7 @@ import javax.ws.rs.ext.ExceptionMapper;
public class ErrorHandler implements ExceptionMapper {
@Override public Response toResponse(Throwable throwable) {
public Response toResponse(Throwable throwable) {
Response.Status status;
status = Response.Status.INTERNAL_SERVER_ERROR;
// return Response.status(status).header("exception", exception.getMessage()).build();

@ -51,9 +51,6 @@
<bean id="serviceBean" class="cdm.api.android.Authentication"/>
<bean id="deviceMgtServiceBean" class="cdm.api.android.Device"/>
<bean id="enrollmentServiceBean" class="cdm.api.android.Enrollment"/>
<bean id="testServiceBean" class="cdm.api.android.Test"/>
<bean id="jsonProvider" class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/>
</beans>

@ -182,7 +182,8 @@
<delete dir="target/dependency-maven-plugin-markers"/>
<delete dir="target/maven-archiver"/>
<delete dir="target/wso2carbon-core-${carbon.kernel.version}"/>
<!--<delete file="target/wso2cdm-${project.version}.jar"/>-->
<delete dir="target/wso2carbon-core-${project.version}"/>
<delete file="target/wso2cdm-${project.version}.jar"/>
<delete dir="target/sources"/>
<delete dir="target/site"/>
<delete dir="target/antrun"/>

@ -7,7 +7,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE
CREATE TABLE IF NOT EXISTS DM_DEVICE
(
ID VARCHAR(20) NOT NULL,
ID INT auto_increment NOT NULL,
DESCRIPTION TEXT NULL DEFAULT NULL,
NAME VARCHAR(100) NULL DEFAULT NULL,
DATE_OF_ENROLLMENT BIGINT NULL DEFAULT NULL,
@ -22,3 +22,5 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE
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
);
-- TO:DO - Remove this INSERT sql statement.
Insert into DM_DEVICE_TYPE (ID,NAME) VALUES (1, 'android');

@ -1,38 +1,11 @@
CREATE TABLE IF NOT EXISTS MBL_OS_VERSION
(
VERSION_ID INT NOT NULL AUTO_INCREMENT,
NAME VARCHAR(45) NULL DEFAULT NULL,
PRIMARY KEY (VERSION_ID)
);
CREATE TABLE IF NOT EXISTS MBL_DEVICE_MODEL
(
MODEL_ID INT NOT NULL AUTO_INCREMENT,
MODEL VARCHAR(45) NULL DEFAULT NULL,
PRIMARY KEY (MODEL_ID)
);
CREATE TABLE IF NOT EXISTS MBL_VENDOR
(
VENDOR_ID INT NOT NULL AUTO_INCREMENT,
VENDOR VARCHAR(45) NULL DEFAULT NULL,
PRIMARY KEY (VENDOR_ID)
);
CREATE TABLE IF NOT EXISTS MBL_DEVICE
(
MOBILE_DEVICE_ID VARCHAR(45) NOT NULL,
REG_ID VARCHAR(45) NOT NULL,
IMEI VARCHAR(45) NOT NULL,
IMSI VARCHAR(45) NOT NULL,
OS_VERSION_ID INT NOT NULL,
DEVICE_MODEL_ID INT NOT NULL,
VENDOR_ID INT NOT NULL,
PRIMARY KEY (MOBILE_DEVICE_ID),
CONSTRAINT fk_DEVICE_OS_VERSION1 FOREIGN KEY (OS_VERSION_ID )
REFERENCES MBL_OS_VERSION (VERSION_ID ) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT fk_DEVICE_DEVICE_MODEL2 FOREIGN KEY (DEVICE_MODEL_ID )
REFERENCES MBL_DEVICE_MODEL (MODEL_ID ) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT fk_DEVICE_VENDOR1 FOREIGN KEY (VENDOR_ID )
REFERENCES MBL_VENDOR (VENDOR_ID ) ON DELETE NO ACTION ON UPDATE NO ACTION
IMSI VARCHAR(45),
OS_VERSION VARCHAR(45) NOT NULL,
DEVICE_MODEL VARCHAR(45) NOT NULL,
VENDOR VARCHAR(45) NOT NULL,
PRIMARY KEY (MOBILE_DEVICE_ID)
);

@ -1,33 +1,3 @@
-- -----------------------------------------------------
-- Table `MBL_OS_VERSION`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_OS_VERSION` (
`VERSION_ID` INT NOT NULL AUTO_INCREMENT,
`VERSION` VARCHAR(45) NULL,
PRIMARY KEY (`VERSION_ID`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `MBL_DEVICE_MODEL`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_DEVICE_MODEL` (
`MODEL_ID` INT NOT NULL AUTO_INCREMENT,
`MODEL` VARCHAR(45) NULL,
PRIMARY KEY (`MODEL_ID`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `MBL_VENDOR`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_VENDOR` (
`VENDOR_ID` INT NOT NULL AUTO_INCREMENT,
`VENDOR` VARCHAR(45) NULL,
PRIMARY KEY (`VENDOR_ID`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `MBL_DEVICE`
-- -----------------------------------------------------
@ -36,28 +6,10 @@ CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
`REG_ID` VARCHAR(45) NULL,
`IMEI` VARCHAR(45) NULL,
`IMSI` VARCHAR(45) NULL,
`OS_VERSION_ID` INT NOT NULL,
`DEVICE_MODEL_ID` INT NOT NULL,
`VENDOR_ID` INT NOT NULL,
PRIMARY KEY (`MOBILE_DEVICE_ID`),
INDEX `fk_DEVICE_OS_VERSION1_idx` (`OS_VERSION_ID` ASC),
INDEX `fk_DEVICE_DEVICE_MODEL2_idx` (`DEVICE_MODEL_ID` ASC),
INDEX `fk_DEVICE_VENDOR1_idx` (`VENDOR_ID` ASC),
CONSTRAINT `fk_DEVICE_OS_VERSION1`
FOREIGN KEY (`OS_VERSION_ID`)
REFERENCES `MBL_OS_VERSION` (`VERSION_ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_DEVICE_DEVICE_MODEL2`
FOREIGN KEY (`DEVICE_MODEL_ID`)
REFERENCES `MBL_DEVICE_MODEL` (`MODEL_ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_DEVICE_VENDOR1`
FOREIGN KEY (`VENDOR_ID`)
REFERENCES `MBL_VENDOR` (`VENDOR_ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
`OS_VERSION` VARCHAR(45) NULL,
`DEVICE_MODEL` VARCHAR(45) NULL,
`VENDOR` VARCHAR(45) NULL,
PRIMARY KEY (`MOBILE_DEVICE_ID`))
ENGINE = InnoDB;

@ -109,7 +109,7 @@
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.device.mgt.mobile.feature:${project.version}
</featureArtifactDef>
<featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.policy.mgt.server.feature:${project.version}
</featureArtifactDef>
<featureArtifactDef>
@ -133,67 +133,70 @@
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.as.runtimes.cxf.feature:${carbon.platform.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.dbconsole.ui.feature:${carbon.platform.version}
</featureArtifactDef>
<!-- API Manager related features -->
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.apimgt.core.feature:${carbon.kernel.version}
</featureArtifactDef>
<featureArtifactDef>
<!-- API Manager related features -->
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.apimgt.core.feature:${carbon.kernel.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.um.ws.service.server.feature:${carbon.platform.version}
</featureArtifactDef>
<featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.identity.oauth.feature:${carbon.platform.version}
</featureArtifactDef>
<featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.identity.oauth.common.feature:${carbon.platform.version}
</featureArtifactDef>
<featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.identity.provider.server.feature:${carbon.platform.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.governance.metadata.server.feature:${carbon.platform.version}
</featureArtifactDef>
<featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.governance.metadata.server.feature:${carbon.platform.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.registry.extensions.server.feature:${carbon.platform.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.identity.core.server.feature:${carbon.platform.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.registry.associations.dependencies.server.feature:${carbon.platform.version}
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.identity.core.server.feature:${carbon.platform.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.registry.community.features.server.feature:${carbon.platform.version}
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.registry.associations.dependencies.server.feature:${carbon.platform.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.registry.core.server.feature:${carbon.platform.version}
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.registry.community.features.server.feature:${carbon.platform.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.registry.core.common.feature:${carbon.platform.version}
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.registry.core.server.feature:${carbon.platform.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.logging.mgt.feature:${carbon.platform.version}
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.registry.core.common.feature:${carbon.platform.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.event.server.feature:${carbon.platform.version}
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.logging.mgt.feature:${carbon.platform.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.databridge.datapublisher.feature:${carbon.platform.version}
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.event.server.feature:${carbon.platform.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.identity.application.authentication.framework.server.feature:${carbon.platform.version}
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.databridge.datapublisher.feature:${carbon.platform.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.idp.mgt.server.feature:${carbon.platform.version}
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.identity.application.authentication.framework.server.feature:${carbon.platform.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.idp.mgt.server.feature:${carbon.platform.version}
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.idp.mgt.server.feature:${carbon.platform.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.idp.mgt.server.feature:${carbon.platform.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.identity.user.profile.server.feature:${carbon.platform.version}
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.identity.user.profile.server.feature:${carbon.platform.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.identity.relying.party.server.feature:${carbon.platform.version}
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.identity.relying.party.server.feature:${carbon.platform.version}
</featureArtifactDef>
</featureArtifacts>
</configuration>
@ -213,10 +216,10 @@
</destination>
<deleteOldProfileFiles>true</deleteOldProfileFiles>
<features>
<feature>
<id>org.wso2.carbon.apimgt.core.feature.group</id>
<version>${carbon.kernel.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.apimgt.core.feature.group</id>
<version>${carbon.kernel.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.ndatasource.feature.group</id>
<version>${carbon.kernel.version}</version>
@ -262,79 +265,85 @@
<version>${carbon.platform.version}</version>
</feature>
<!-- API Manager related features -->
<feature>
<!-- API Manager related features -->
<feature>
<id>org.wso2.carbon.um.ws.service.server.feature.group</id>
<version>${carbon.platform.version}</version>
<version>${carbon.platform.version}</version>
</feature>
<feature>
<feature>
<id>org.wso2.carbon.identity.oauth.server.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
<feature>
<feature>
<id>org.wso2.carbon.identity.oauth.common.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
<feature>
<feature>
<id>org.wso2.carbon.identity.provider.server.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.governance.metadata.server.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
<feature>
<feature>
<id>org.wso2.carbon.governance.metadata.server.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.registry.extensions.server.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
<feature>
<feature>
<id>org.wso2.carbon.identity.core.server.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
<feature>
<feature>
<id>org.wso2.carbon.registry.associations.dependencies.server.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
<feature>
<feature>
<id>org.wso2.carbon.registry.community.features.server.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
<feature>
<feature>
<id>org.wso2.carbon.registry.core.server.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
<feature>
<feature>
<id>org.wso2.carbon.registry.core.common.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
<feature>
<feature>
<id>org.wso2.carbon.logging.mgt.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
<feature>
<feature>
<id>org.wso2.carbon.event.server.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
<feature>
<feature>
<id>org.wso2.carbon.databridge.datapublisher.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.identity.application.authentication.framework.server.feature.group</id>
<feature>
<id>
org.wso2.carbon.identity.application.authentication.framework.server.feature.group
</id>
<version>${carbon.platform.version}</version>
</feature>
<feature>
<feature>
<id>org.wso2.carbon.idp.mgt.server.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
<feature>
<feature>
<id>org.wso2.carbon.identity.user.profile.server.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
<feature>
<feature>
<id>org.wso2.carbon.identity.relying.party.server.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.dbconsole.ui.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
</features>
</configuration>
</execution>
@ -364,7 +373,7 @@
</plugins>
</build>
<properties>
<apim.version>1.2.1</apim.version>
</properties>
<properties>
<apim.version>1.2.1</apim.version>
</properties>
</project>

Loading…
Cancel
Save