diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Device.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Device.java index d3eac453b8..b71a27071d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Device.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Device.java @@ -144,11 +144,11 @@ public class Device { this.type = type; } @XmlElement - public List getProperties() { + public List getProperties() { return properties; } - public void setProperties(List properties) { + public void setProperties(List properties) { this.properties = properties; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManager.java index a7c6ef8154..6f62ea8d0e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManager.java @@ -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); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java index 2c9cb0d585..ea9c148c81 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java @@ -37,4 +37,5 @@ public interface DeviceDAO { List getDevices() throws DeviceManagementDAOException; + Integer getDeviceTypeIdByDeviceTypeName(String type) throws DeviceManagementDAOException; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java index ec48c4c10f..dd85092825 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java @@ -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(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java index 5f81287390..60ec9785f2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java @@ -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; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml index 510ee66d72..70e9da226f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml @@ -82,6 +82,14 @@ org.eclipse.osgi org.eclipse.osgi.services + + org.wso2.carbon + org.wso2.carbon.apimgt.impl + + + org.wso2.carbon + org.wso2.carbon.apimgt.core + \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagerService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagerService.java index 805345e743..78791808eb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagerService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagerService.java @@ -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 - -} +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/APIConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/APIConfig.java new file mode 100644 index 0000000000..a544d56560 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/APIConfig.java @@ -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; + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/APIPublisherConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/APIPublisherConfig.java new file mode 100644 index 0000000000..c496818174 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/APIPublisherConfig.java @@ -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 apis; + + @XmlElement(name = "APIs") + public List getApis() { + return apis; + } + + public void setApis(List apis) { + this.apis = apis; + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/MobileDeviceConfigurationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/MobileDeviceConfigurationManager.java index 1a24811996..3b69a71e6e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/MobileDeviceConfigurationManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/MobileDeviceConfigurationManager.java @@ -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(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/MobileDeviceManagementConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/MobileDeviceManagementConfig.java index 203245e5bd..d7bff0f5ab 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/MobileDeviceManagementConfig.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/MobileDeviceManagementConfig.java @@ -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; + } + } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/datasource/MobileDataSourceConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/datasource/MobileDataSourceConfig.java index a3e3f6ae0b..366cd60a5b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/datasource/MobileDataSourceConfig.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/datasource/MobileDataSourceConfig.java @@ -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; } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceDAO.java index 16330df10c..8cba1f8a07 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceDAO.java @@ -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; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceDAOFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceDAOFactory.java deleted file mode 100644 index fabb81d8d3..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceDAOFactory.java +++ /dev/null @@ -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); - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceManagementDAOFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceManagementDAOFactory.java index 65750447d5..c7bc7922a2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceManagementDAOFactory.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceManagementDAOFactory.java @@ -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 jndiPropertyList = - jndiConfig.getJndiProperties(); - if (jndiPropertyList != null) { - Hashtable jndiProperties = new Hashtable(); - 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); + } } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceModelDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceModelDAO.java deleted file mode 100644 index 768f297231..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceModelDAO.java +++ /dev/null @@ -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; -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceVendorDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceVendorDAO.java deleted file mode 100644 index 4a4d24bf7e..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceVendorDAO.java +++ /dev/null @@ -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; -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileOSVersionDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileOSVersionDAO.java deleted file mode 100644 index dcffc528b6..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileOSVersionDAO.java +++ /dev/null @@ -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; -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceDAOImpl.java index d0ab883d69..890c7c8da1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceDAOImpl.java @@ -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); + } } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceModelDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceModelDAOImpl.java deleted file mode 100644 index 04dbd9c654..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceModelDAOImpl.java +++ /dev/null @@ -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 { - - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceVendorDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceVendorDAOImpl.java deleted file mode 100644 index 3908ef3ba0..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceVendorDAOImpl.java +++ /dev/null @@ -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 { - - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileOSVersionDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileOSVersionDAOImpl.java deleted file mode 100644 index 4296ec974a..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileOSVersionDAOImpl.java +++ /dev/null @@ -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 { - - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/util/MobileDeviceManagementDAOUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/util/MobileDeviceManagementDAOUtil.java index bc210f8ffa..104de0fd72 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/util/MobileDeviceManagementDAOUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/util/MobileDeviceManagementDAOUtil.java @@ -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 jndiPropertyList = + jndiConfig.getJndiProperties(); + if (jndiPropertyList != null) { + Hashtable jndiProperties = new Hashtable(); + 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 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 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); + } } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDevice.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDevice.java index f7b1d14b1f..f054b2bf5f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDevice.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDevice.java @@ -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; } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDeviceModel.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDeviceModel.java deleted file mode 100644 index b5d5e5ebbb..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDeviceModel.java +++ /dev/null @@ -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; - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDeviceVendor.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDeviceVendor.java deleted file mode 100644 index 2d48af52a0..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDeviceVendor.java +++ /dev/null @@ -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; - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileOSVersion.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileOSVersion.java deleted file mode 100644 index 32a56b6fcc..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileOSVersion.java +++ /dev/null @@ -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; - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/internal/MobileDeviceManagementBundleActivator.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/internal/MobileDeviceManagementBundleActivator.java index 9d3e08cadd..43a8a07008 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/internal/MobileDeviceManagementBundleActivator.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/internal/MobileDeviceManagementBundleActivator.java @@ -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 dataSourceListeners = new ArrayList(); + 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 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 apiConfigs = + MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig(). + getApiPublisherConfig().getApis(); + for (APIConfig apiConfig : apiConfigs) { + DeviceManagementAPIPublisherUtil.publishAPI(apiConfig); } } + private void removeAPIs() throws DeviceManagementException { + List apiConfigs = + MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig(). + getApiPublisherConfig().getApis(); + for (APIConfig apiConfig : apiConfigs) { + DeviceManagementAPIPublisherUtil.removeAPI(apiConfig); + } + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/util/DeviceManagementAPIPublisherUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/util/DeviceManagementAPIPublisherUtil.java new file mode 100644 index 0000000000..79c276f8bf --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/util/DeviceManagementAPIPublisherUtil.java @@ -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 httpMethods; + + static { + httpMethods = new ArrayList(); + 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 getURITemplates(String endpoint, String authType) { + Set uriTemplates = new LinkedHashSet(); + 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; + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/util/MobileDeviceManagerUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/util/DeviceManagementUtil.java similarity index 54% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/util/MobileDeviceManagerUtil.java rename to components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/util/DeviceManagementUtil.java index c5b9940fb6..92b257e958 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/util/MobileDeviceManagerUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/util/DeviceManagementUtil.java @@ -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 jndiPropertyList = - jndiConfig.getJndiProperties(); - if (jndiPropertyList != null) { - Hashtable jndiProperties = new Hashtable(); - 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; - } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/util/MobileDeviceManagementSchemaInitializer.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/util/MobileDeviceManagementSchemaInitializer.java index f62b09cc10..24e5b57bc3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/util/MobileDeviceManagementSchemaInitializer.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/util/MobileDeviceManagementSchemaInitializer.java @@ -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) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/util/MobileDeviceManagementUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/util/MobileDeviceManagementUtil.java new file mode 100644 index 0000000000..3cc4af6619 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/util/MobileDeviceManagementUtil.java @@ -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 propertyList = new ArrayList(); + 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; + } +} diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index a154b9ef33..ea9baa27c9 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -40,6 +40,7 @@ org.wso2.carbon.device.mgt.core org.wso2.carbon.device.mgt.common org.wso2.carbon.device.mgt.mobile.impl + org.wso2.carbon.device.mgt.oauth.token.handler @@ -74,6 +75,26 @@ h2-database-engine ${orbit.version.h2.engine} + + org.wso2.carbon + org.wso2.carbon.apimgt.core + ${apim.version} + + + org.wso2.carbon + org.wso2.carbon.apimgt.impl + ${apim.version} + + + org.apache.tomcat.wso2 + tomcat + ${orbit.version.tomcat} + + + org.wso2.carbon + org.wso2.carbon.tomcat.ext + 4.3.0-SNAPSHOT + @@ -98,5 +119,7 @@ 1.2.140.wso2v3 + 1.2.1 + 7.0.52.wso2v5 diff --git a/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/pom.xml b/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/pom.xml new file mode 100644 index 0000000000..b53ef4bba9 --- /dev/null +++ b/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/pom.xml @@ -0,0 +1,83 @@ + + + + + + org.wso2.carbon + key-mgt + 2.0.0-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon + org.wso2.carbon.key.mgt.handler.valve + 2.0.0-SNAPSHOT + bundle + WSO2 Carbon - Key Management Handler Valve + WSO2 Carbon - Key Management Handler Valve + http://wso2.org + + + + + org.apache.felix + maven-bundle-plugin + true + + + ${project.artifactId} + ${project.artifactId} + org.wso2.carbon.tomcat.patch + + org.wso2.carbon.key.mgt.handler.valve.* + + tomcat + + + + + + + + + org.apache.tomcat.wso2 + tomcat + + + org.wso2.carbon + org.wso2.carbon.apimgt.core + + + org.wso2.carbon + org.wso2.carbon.apimgt.impl + + + org.wso2.carbon + org.wso2.carbon.logging + + + org.wso2.carbon + org.wso2.carbon.tomcat.ext + + + + + diff --git a/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve/APIFaultException.java b/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve/APIFaultException.java new file mode 100644 index 0000000000..db0074724b --- /dev/null +++ b/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve/APIFaultException.java @@ -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; + } + +} diff --git a/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve/HandlerConstants.java b/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve/HandlerConstants.java new file mode 100644 index 0000000000..e5e8cf7332 --- /dev/null +++ b/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve/HandlerConstants.java @@ -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"; + +} diff --git a/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve/HandlerUtil.java b/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve/HandlerUtil.java new file mode 100644 index 0000000000..42020e0178 --- /dev/null +++ b/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve/HandlerUtil.java @@ -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; + } + +} diff --git a/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve/OAuthTokenValidatorValve.java b/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve/OAuthTokenValidatorValve.java new file mode 100644 index 0000000000..70e5310725 --- /dev/null +++ b/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve/OAuthTokenValidatorValve.java @@ -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 '" + * ); + */ + } + + 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 params = request.getParameterNames(); + String paramName; + while (params.hasMoreElements()) { + paramName = params.nextElement(); + if (paramName.endsWith("wsdl") || paramName.endsWith("wadl")) { + getNext().invoke(request, response); + return; + } + } + } + } + +} diff --git a/components/key-mgt/pom.xml b/components/key-mgt/pom.xml new file mode 100644 index 0000000000..e427627aff --- /dev/null +++ b/components/key-mgt/pom.xml @@ -0,0 +1,117 @@ + + + + + + + org.wso2.carbon + wso2cdm-parent + 2.0.0-SNAPSHOT + ../../pom.xml + + + 4.0.0 + org.wso2.carbon + key-mgt + 2.0.0-SNAPSHOT + pom + WSO2 Carbon - Device Management Component + http://wso2.org + + + org.wso2.carbon.key.mgt.handler.valve + + + + + + org.eclipse.osgi + org.eclipse.osgi + 3.8.1.v20120830-144521 + + + org.eclipse.equinox + org.eclipse.equinox.common + 3.6.100.v20120522-1841 + + + org.wso2.carbon + org.wso2.carbon.logging + 4.3.0-SNAPSHOT + + + org.wso2.carbon + org.wso2.carbon.device.mgt.common + 2.0.0-SNAPSHOT + + + org.eclipse.osgi + org.eclipse.osgi.services + 3.3.100.v20120522-1822 + + + org.wso2.carbon + org.wso2.carbon.apimgt.core + ${apim.version} + + + org.wso2.carbon + org.wso2.carbon.apimgt.impl + ${apim.version} + + + org.apache.tomcat.wso2 + tomcat + ${orbit.version.tomcat} + + + org.wso2.carbon + org.wso2.carbon.tomcat.ext + 4.3.0-SNAPSHOT + + + + + + + + + org.apache.felix + maven-scr-plugin + 1.7.2 + + + generate-scr-scrdescriptor + + scr + + + + + + + + + 1.2.140.wso2v3 + 1.2.1 + 7.0.52.wso2v5 + + diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java index 96d687365b..a52bd487e6 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java @@ -24,6 +24,15 @@ public class Policy { private int id; private String policyName; private List featuresList; + private boolean generic; + + public boolean isGeneric() { + return generic; + } + + public void setGeneric(boolean generic) { + this.generic = generic; + } public int getId() { return id; diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/conf/mobile-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/conf/mobile-config.xml index e44dcfaf4e..7a3963fbdb 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/conf/mobile-config.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/conf/mobile-config.xml @@ -23,4 +23,15 @@ - \ No newline at end of file + + + + enrollment + admin + enrollment + 1.0.0 + http://localhost:9763/ + http,https + + + diff --git a/product/modules/agents/android/jax-rs/pom.xml b/product/modules/agents/android/jax-rs/pom.xml index 49ccbaf328..ff4e139e64 100644 --- a/product/modules/agents/android/jax-rs/pom.xml +++ b/product/modules/agents/android/jax-rs/pom.xml @@ -169,7 +169,7 @@ org.codehaus.jackson jackson-jaxrs - 1.1.1 + 1.9.0 diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Authentication.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Authentication.java index cff7c08fcc..b5687928b1 100644 --- a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Authentication.java +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Authentication.java @@ -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"; } } diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Device.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Device.java index 0b1cdf35e9..cc75b3a89e 100644 --- a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Device.java +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Device.java @@ -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 getAllDevices() { - - List 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 getAllDevices() { + List 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; + } } diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Enrollment.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Enrollment.java index cd68364cce..f2eb449d75 100644 --- a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Enrollment.java +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Enrollment.java @@ -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; + } + } } diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Test.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Test.java deleted file mode 100644 index 2c7e6fd25c..0000000000 --- a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Test.java +++ /dev/null @@ -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 getAllDevices() { - - Device dev = new Device(); - dev.setName("test1"); - dev.setDateOfEnrolment(11111111L); - dev.setDateOfLastUpdate(992093209L); - dev.setDescription("sassasaas"); - - ArrayList listdevices = new ArrayList(); - listdevices.add(dev); - - return listdevices; - } - -} diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/ErrorHandler.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/ErrorHandler.java index 14603fd1b5..6fa07dba1f 100644 --- a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/ErrorHandler.java +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/ErrorHandler.java @@ -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(); diff --git a/product/modules/agents/android/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml b/product/modules/agents/android/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml index bab3022d98..3f42f416b0 100644 --- a/product/modules/agents/android/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/product/modules/agents/android/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -51,9 +51,6 @@ - - - diff --git a/product/modules/distribution/pom.xml b/product/modules/distribution/pom.xml index ab110a0ff2..b859527b8c 100644 --- a/product/modules/distribution/pom.xml +++ b/product/modules/distribution/pom.xml @@ -182,7 +182,8 @@ - + + diff --git a/product/modules/distribution/src/repository/dbscripts/cdm/h2.sql b/product/modules/distribution/src/repository/dbscripts/cdm/h2.sql index 29f5b3075f..dadcbd080c 100644 --- a/product/modules/distribution/src/repository/dbscripts/cdm/h2.sql +++ b/product/modules/distribution/src/repository/dbscripts/cdm/h2.sql @@ -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, @@ -21,4 +21,6 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE PRIMARY KEY (ID), CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID ) REFERENCES DM_DEVICE_TYPE (ID ) ON DELETE NO ACTION ON UPDATE NO ACTION -); +); +-- TO:DO - Remove this INSERT sql statement. +Insert into DM_DEVICE_TYPE (ID,NAME) VALUES (1, 'android'); diff --git a/product/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql b/product/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql index f36a034bd5..ed495ac190 100644 --- a/product/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql +++ b/product/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql @@ -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) ); \ No newline at end of file diff --git a/product/modules/distribution/src/repository/dbscripts/cdm/plugins/mysql.sql b/product/modules/distribution/src/repository/dbscripts/cdm/plugins/mysql.sql index 9c57710484..afc4f32d9e 100644 --- a/product/modules/distribution/src/repository/dbscripts/cdm/plugins/mysql.sql +++ b/product/modules/distribution/src/repository/dbscripts/cdm/plugins/mysql.sql @@ -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; diff --git a/product/modules/p2-profile-gen/pom.xml b/product/modules/p2-profile-gen/pom.xml index 3ea1dce4b9..acafff81fe 100644 --- a/product/modules/p2-profile-gen/pom.xml +++ b/product/modules/p2-profile-gen/pom.xml @@ -109,7 +109,7 @@ org.wso2.carbon:org.wso2.carbon.device.mgt.mobile.feature:${project.version} - + org.wso2.carbon:org.wso2.carbon.policy.mgt.server.feature:${project.version} @@ -133,67 +133,70 @@ org.wso2.carbon:org.wso2.carbon.as.runtimes.cxf.feature:${carbon.platform.version} + + org.wso2.carbon:org.wso2.carbon.dbconsole.ui.feature:${carbon.platform.version} + - - - org.wso2.carbon:org.wso2.carbon.apimgt.core.feature:${carbon.kernel.version} - - + + + org.wso2.carbon:org.wso2.carbon.apimgt.core.feature:${carbon.kernel.version} + + org.wso2.carbon:org.wso2.carbon.um.ws.service.server.feature:${carbon.platform.version} - + org.wso2.carbon:org.wso2.carbon.identity.oauth.feature:${carbon.platform.version} - + org.wso2.carbon:org.wso2.carbon.identity.oauth.common.feature:${carbon.platform.version} - + org.wso2.carbon:org.wso2.carbon.identity.provider.server.feature:${carbon.platform.version} - - org.wso2.carbon:org.wso2.carbon.governance.metadata.server.feature:${carbon.platform.version} - - + + org.wso2.carbon:org.wso2.carbon.governance.metadata.server.feature:${carbon.platform.version} + + org.wso2.carbon:org.wso2.carbon.registry.extensions.server.feature:${carbon.platform.version} - - org.wso2.carbon:org.wso2.carbon.identity.core.server.feature:${carbon.platform.version} - - - org.wso2.carbon:org.wso2.carbon.registry.associations.dependencies.server.feature:${carbon.platform.version} + + org.wso2.carbon:org.wso2.carbon.identity.core.server.feature:${carbon.platform.version} - - org.wso2.carbon:org.wso2.carbon.registry.community.features.server.feature:${carbon.platform.version} + + org.wso2.carbon:org.wso2.carbon.registry.associations.dependencies.server.feature:${carbon.platform.version} - - org.wso2.carbon:org.wso2.carbon.registry.core.server.feature:${carbon.platform.version} + + org.wso2.carbon:org.wso2.carbon.registry.community.features.server.feature:${carbon.platform.version} - - org.wso2.carbon:org.wso2.carbon.registry.core.common.feature:${carbon.platform.version} + + org.wso2.carbon:org.wso2.carbon.registry.core.server.feature:${carbon.platform.version} - - org.wso2.carbon:org.wso2.carbon.logging.mgt.feature:${carbon.platform.version} + + org.wso2.carbon:org.wso2.carbon.registry.core.common.feature:${carbon.platform.version} - - org.wso2.carbon:org.wso2.carbon.event.server.feature:${carbon.platform.version} + + org.wso2.carbon:org.wso2.carbon.logging.mgt.feature:${carbon.platform.version} - - org.wso2.carbon:org.wso2.carbon.databridge.datapublisher.feature:${carbon.platform.version} + + org.wso2.carbon:org.wso2.carbon.event.server.feature:${carbon.platform.version} - - org.wso2.carbon:org.wso2.carbon.identity.application.authentication.framework.server.feature:${carbon.platform.version} + + org.wso2.carbon:org.wso2.carbon.databridge.datapublisher.feature:${carbon.platform.version} - - org.wso2.carbon:org.wso2.carbon.idp.mgt.server.feature:${carbon.platform.version} + + org.wso2.carbon:org.wso2.carbon.identity.application.authentication.framework.server.feature:${carbon.platform.version} - - org.wso2.carbon:org.wso2.carbon.idp.mgt.server.feature:${carbon.platform.version} + + org.wso2.carbon:org.wso2.carbon.idp.mgt.server.feature:${carbon.platform.version} + + + org.wso2.carbon:org.wso2.carbon.idp.mgt.server.feature:${carbon.platform.version} - - org.wso2.carbon:org.wso2.carbon.identity.user.profile.server.feature:${carbon.platform.version} + + org.wso2.carbon:org.wso2.carbon.identity.user.profile.server.feature:${carbon.platform.version} - - org.wso2.carbon:org.wso2.carbon.identity.relying.party.server.feature:${carbon.platform.version} + + org.wso2.carbon:org.wso2.carbon.identity.relying.party.server.feature:${carbon.platform.version} @@ -213,10 +216,10 @@ true - - org.wso2.carbon.apimgt.core.feature.group - ${carbon.kernel.version} - + + org.wso2.carbon.apimgt.core.feature.group + ${carbon.kernel.version} + org.wso2.carbon.ndatasource.feature.group ${carbon.kernel.version} @@ -262,79 +265,85 @@ ${carbon.platform.version} - - + + org.wso2.carbon.um.ws.service.server.feature.group - ${carbon.platform.version} + ${carbon.platform.version} - + org.wso2.carbon.identity.oauth.server.feature.group ${carbon.platform.version} - + org.wso2.carbon.identity.oauth.common.feature.group ${carbon.platform.version} - + org.wso2.carbon.identity.provider.server.feature.group ${carbon.platform.version} - - org.wso2.carbon.governance.metadata.server.feature.group - ${carbon.platform.version} - - + + org.wso2.carbon.governance.metadata.server.feature.group + ${carbon.platform.version} + + org.wso2.carbon.registry.extensions.server.feature.group ${carbon.platform.version} - + org.wso2.carbon.identity.core.server.feature.group ${carbon.platform.version} - + org.wso2.carbon.registry.associations.dependencies.server.feature.group ${carbon.platform.version} - + org.wso2.carbon.registry.community.features.server.feature.group ${carbon.platform.version} - + org.wso2.carbon.registry.core.server.feature.group ${carbon.platform.version} - + org.wso2.carbon.registry.core.common.feature.group ${carbon.platform.version} - + org.wso2.carbon.logging.mgt.feature.group ${carbon.platform.version} - + org.wso2.carbon.event.server.feature.group ${carbon.platform.version} - + org.wso2.carbon.databridge.datapublisher.feature.group ${carbon.platform.version} - - org.wso2.carbon.identity.application.authentication.framework.server.feature.group + + + org.wso2.carbon.identity.application.authentication.framework.server.feature.group + ${carbon.platform.version} - + org.wso2.carbon.idp.mgt.server.feature.group ${carbon.platform.version} - + org.wso2.carbon.identity.user.profile.server.feature.group ${carbon.platform.version} - + org.wso2.carbon.identity.relying.party.server.feature.group ${carbon.platform.version} + + org.wso2.carbon.dbconsole.ui.feature.group + ${carbon.platform.version} + @@ -364,7 +373,7 @@ - - 1.2.1 - + + 1.2.1 +